Automatically format python files

[?]
Jul 11, 2021, 8:56 PM
3QGP6RXLMNWYWMACHKKYEVECRXP7ESGOSWTEY72O46VLXQR5O6IAC

Dependencies

  • [2] RT3FMMOB Fix total crust mass calculation (ie don't add age)
  • [3] TCRWQZ2C Model trainer: use less preferred activation function because tfjs can deserialize it
  • [4] ZLSXVDET Model trainer: export model in tfjs format once trained
  • [5] XYPKZANT Model trainer: Make the shore focused loss function even more focused
  • [6] TZVTKOJE Use named variables for planetary radius
  • [7] IGYI5RVV Figure out how to draw on the sdl2 window
  • [8] FL3C6ERZ Assume python is being run with -m switch
  • [9] EB3DTD43 Model trainer: use ground altitude instead of crust mass distribution
  • [10] ALMG52BO model trainer: speed up by waiting 15 seconds between monitor renders
  • [11] CWOSQTC4 Trust tensorflow's thread safety (it wasn't the cause of an earlier bug)
  • [12] 6W7MFV2F D20-based neural network architecture
  • [13] QMNTEX7P Try a loss function that has higher values for errors near sea level
  • [14] 7ML3OFE7 Model trainer: initial train and visualize thread pair (total crust mass; todo: altitude instead)
  • [15] 4IXWCEHM Gamma correction
  • [16] SJHJS463 Model trainer: main function to open sdl window and launch second thread for actual training
  • [17] ABITXOUU Model trainer: Add provisional colouration
  • [18] F5KOGCLK Expand model capacity
  • [19] 3AJMKZ7C Model trainer: include land mass calculation in click handler
  • [20] X5U7KRUI Parse some of the data into tensors
  • [21] 6AXPZL5P Try to offload tight loop to rust (for now it segfaults)
  • [22] E742MTJA Fix segfault (don't pass pointers between functions in different SDL versions), minor refactor
  • [23] 2ABZP2KN Model trainer: save map.png after training
  • [24] ROQCAPZJ Begin function for showing the map (for now just opens SDL window)
  • [25] J6HV4MNJ Model trainer: mouse click handler (prints normalized vector from planet's center)
  • [26] TCMUFA6E Try some different hyperparameters
  • [27] ZM2EMAZO Start doing python multi-module stuff properly
  • [28] PG7KSKJL Add surface distance measurement to mouse click handler
  • [29] 5AMZXFS5 model trainer: function to generate inputs to pass neural network for rendering equirectangular projection

Change contents

  • edit in trainmodel/src/simsave.py at line 5
    [7.85]
    [7.85]
  • replacement in trainmodel/src/simsave.py at line 8
    [7.103][7.103:1084](),[7.1084][2.0:234]()
    def __init__(self, stream):
    def check(item):
    if type(item) == dict:
    return {k: check(v) for k, v in item.items()}
    elif type(item) == list:
    return list(map(check, item))
    elif type(item) == str and item.startswith('buffer:'):
    return base64.b64decode(item[len('buffer:'):])
    else:
    return item
    self.raw = check(json.load(stream))
    def vertex(obj):
    return [obj['x'], obj['y'], obj['z']]
    self.vertices = tf.convert_to_tensor(list(map(vertex, self.raw['model']['bodies']['world']['grid']['vertices'])), dtype=tf.float32)
    crust = tf.convert_to_tensor(list(map(lambda x: x[0], struct.iter_unpack('f', self.raw['model']['bodies']['world']['lithosphere']['total_crust']))))
    crust = tf.reshape(crust, (8, self.vertices.shape[0]))
    self.crust_layers = {SimResult.crust_columns()[i]: crust[i] for i in range(0,8)}
    total_crust = tf.zeros((self.vertices.shape[0],), dtype=tf.float32)
    for k, v in self.crust_layers.items():
    if k != 'age':
    total_crust += v
    self.crust_layers['total'] = total_crust
    [7.103]
    [7.1131]
    def __init__(self, stream):
    def check(item):
    if type(item) == dict:
    return {k: check(v) for k, v in item.items()}
    elif type(item) == list:
    return list(map(check, item))
    elif type(item) == str and item.startswith('buffer:'):
    return base64.b64decode(item[len('buffer:'):])
    else:
    return item
    self.raw = check(json.load(stream))
    def vertex(obj):
    return [obj['x'], obj['y'], obj['z']]
  • replacement in trainmodel/src/simsave.py at line 24
    [7.1132][7.1132:1184]()
    def seed(self):
    return self.raw['seed']
    [7.1132]
    [7.1277]
    self.vertices = tf.convert_to_tensor(list(
    map(vertex, self.raw['model']['bodies']['world']['grid']['vertices'])),
    dtype=tf.float32)
    crust = tf.convert_to_tensor(
    list(
    map(
    lambda x: x[0],
    struct.iter_unpack(
    'f', self.raw['model']['bodies']['world']['lithosphere']
    ['total_crust']))))
    crust = tf.reshape(crust, (8, self.vertices.shape[0]))
    self.crust_layers = {
    SimResult.crust_columns()[i]: crust[i]
    for i in range(0, 8)
    }
    total_crust = tf.zeros((self.vertices.shape[0], ), dtype=tf.float32)
    for k, v in self.crust_layers.items():
    if k != 'age':
    total_crust += v
    self.crust_layers['total'] = total_crust
  • replacement in trainmodel/src/simsave.py at line 45
    [7.1278][7.1278:1435]()
    def crust_columns():
    return ['sediment','sedimentary','metamorphic','felsic_plutonic','felsic_volcanic','mafic_volcanic','mafic_plutonic','age']
    [7.1278]
    [7.1435]
    def seed(self):
    return self.raw['seed']
  • edit in trainmodel/src/simsave.py at line 48
    [7.1436]
    def crust_columns():
    return [
    'sediment', 'sedimentary', 'metamorphic', 'felsic_plutonic',
    'felsic_volcanic', 'mafic_volcanic', 'mafic_plutonic', 'age'
    ]
  • replacement in trainmodel/src/nativehelpers.py at line 6
    [7.212][7.212:359]()
    native = ctypes.cdll.LoadLibrary(os.path.dirname(os.path.realpath(__file__)) + '/helpers.' + ('dylib' if platform.system() == 'Darwin' else 'so'))
    [7.212]
    [7.393]
    native = ctypes.cdll.LoadLibrary(
    os.path.dirname(os.path.realpath(__file__)) + '/helpers.' +
    ('dylib' if platform.system() == 'Darwin' else 'so'))
  • replacement in trainmodel/src/nativehelpers.py at line 10
    [7.394][7.359:451](),[7.359][7.359:451]()
    native.render_tensor.argtypes = [ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_int]
    [7.394]
    [7.451]
    native.render_tensor.argtypes = [
    ctypes.c_void_p, ctypes.c_int, ctypes.c_int, ctypes.c_int
    ]
  • replacement in trainmodel/src/nativehelpers.py at line 16
    [7.562][7.395:491]()
    native.equirectangular.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
    [7.562]
    [7.491]
    native.equirectangular.argtypes = [
    ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int
    ]
  • replacement in trainmodel/src/nativehelpers.py at line 21
    [7.1][7.1:134]()
    native.colourize_heightmap.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int]
    [7.1]
    [7.134]
    native.colourize_heightmap.argtypes = [
    ctypes.POINTER(ctypes.c_double),
    ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int
    ]
  • replacement in trainmodel/src/nativehelpers.py at line 27
    [7.1][7.1:129]()
    native.landmass_steradians.argtypes = [ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int]
    [7.1]
    [7.129]
    native.landmass_steradians.argtypes = [
    ctypes.POINTER(ctypes.c_double), ctypes.c_int, ctypes.c_int, ctypes.c_int,
    ctypes.c_int
    ]
  • edit in trainmodel/src/model.py at line 5
    [7.22]
    [7.0]
  • replacement in trainmodel/src/model.py at line 8
    [7.26][3.0:402](),[3.402][7.0:349](),[7.376][7.0:349](),[7.349][3.403:1055](),[3.1055][7.1312:1367](),[7.1312][7.1312:1367]()
    layer1 = keras.layers.Dense(20, activation=keras.activations.softplus)(inputs)
    layer2 = keras.layers.Dense(20, activation=keras.activations.softplus)(layer1)
    layer3 = keras.layers.Dense(20, activation=keras.activations.softplus)(keras.layers.concatenate([layer1,layer2]))
    layer4 = keras.layers.Dense(20, activation=keras.activations.softplus)(keras.layers.concatenate([layer1,layer2]))
    layer5 = keras.layers.Dense(88, activation=keras.activations.relu)(keras.layers.concatenate([layer2,layer3]))
    layer6 = keras.layers.Dense(88, activation=keras.activations.relu)(keras.layers.concatenate([layer2,layer4,layer5]))
    layer7 = keras.layers.Dense(88, activation=keras.activations.relu)(keras.layers.concatenate([layer5,layer6]))
    layer8 = keras.layers.Dense(20, activation=keras.activations.softplus)(keras.layers.concatenate([layer3,layer5,layer7]))
    layer9 = keras.layers.Dense(20, activation=keras.activations.softplus)(keras.layers.concatenate([layer4,layer6,layer7]))
    layer10 = keras.layers.Dense(20, activation=keras.activations.softplus)(keras.layers.concatenate([layer7,layer8,layer9]))
    layer11 = keras.layers.Dense(20, activation=keras.activations.softplus)(keras.layers.concatenate([layer1,layer3,layer8,layer10]))
    layer12 = keras.layers.Dense(20, activation=keras.activations.softplus)(keras.layers.concatenate([layer1,layer4,layer9,layer10,layer11]))
    return keras.layers.concatenate([layer11,layer12])
    [7.26]
    [7.1194]
    layer1 = keras.layers.Dense(20,
    activation=keras.activations.softplus)(inputs)
    layer2 = keras.layers.Dense(20,
    activation=keras.activations.softplus)(layer1)
    layer3 = keras.layers.Dense(20, activation=keras.activations.softplus)(
    keras.layers.concatenate([layer1, layer2]))
    layer4 = keras.layers.Dense(20, activation=keras.activations.softplus)(
    keras.layers.concatenate([layer1, layer2]))
    layer5 = keras.layers.Dense(88, activation=keras.activations.relu)(
    keras.layers.concatenate([layer2, layer3]))
    layer6 = keras.layers.Dense(88, activation=keras.activations.relu)(
    keras.layers.concatenate([layer2, layer4, layer5]))
    layer7 = keras.layers.Dense(88, activation=keras.activations.relu)(
    keras.layers.concatenate([layer5, layer6]))
    layer8 = keras.layers.Dense(20, activation=keras.activations.softplus)(
    keras.layers.concatenate([layer3, layer5, layer7]))
    layer9 = keras.layers.Dense(20, activation=keras.activations.softplus)(
    keras.layers.concatenate([layer4, layer6, layer7]))
    layer10 = keras.layers.Dense(20, activation=keras.activations.softplus)(
    keras.layers.concatenate([layer7, layer8, layer9]))
    layer11 = keras.layers.Dense(20, activation=keras.activations.softplus)(
    keras.layers.concatenate([layer1, layer3, layer8, layer10]))
    layer12 = keras.layers.Dense(20, activation=keras.activations.softplus)(
    keras.layers.concatenate([layer1, layer4, layer9, layer10, layer11]))
    return keras.layers.concatenate([layer11, layer12])
  • edit in trainmodel/src/model.py at line 34
    [7.1195]
    [7.1195]
  • replacement in trainmodel/src/model.py at line 36
    [7.1208][7.1208:1245](),[7.1245][7.1368:1535](),[7.1535][7.1668:1745](),[7.1668][7.1668:1745]()
    inputs = keras.Input(shape=(3,))
    d1 = icosahedral(inputs)
    d2 = icosahedral(inputs)
    outputs = keras.layers.Dense(1, activation=keras.activations.sigmoid)(keras.layers.concatenate([d1,d2]))
    return keras.Model(inputs=inputs, outputs=outputs, name="geology_model")
    [7.1208]
    [7.1745]
    inputs = keras.Input(shape=(3, ))
    d1 = icosahedral(inputs)
    d2 = icosahedral(inputs)
    outputs = keras.layers.Dense(1, activation=keras.activations.sigmoid)(
    keras.layers.concatenate([d1, d2]))
    return keras.Model(inputs=inputs, outputs=outputs, name="geology_model")
  • replacement in trainmodel/src/model.py at line 45
    [7.40][5.0:106](),[5.106][7.130:185](),[7.266][7.130:185](),[7.130][7.130:185]()
    y_true = tf.math.asinh((y_true - 0.1) * 5.) / 5.
    y_pred = tf.math.asinh((y_pred - 0.1) * 5.) / 5.
    return tf.math.reduce_mean((y_true - y_pred) ** 2)
    [7.40]
    [7.185]
    y_true = tf.math.asinh((y_true - 0.1) * 5.) / 5.
    y_pred = tf.math.asinh((y_pred - 0.1) * 5.) / 5.
    return tf.math.reduce_mean((y_true - y_pred)**2)
  • replacement in trainmodel/src/model.py at line 51
    [7.1776][7.23:114]()
    return (simresult.vertices, (geology.isostatic_displacement(simresult) + 1.) / 25000.)
    [7.1776]
    [7.1872]
    return (simresult.vertices,
    (geology.isostatic_displacement(simresult) + 1.) / 25000.)
  • replacement in trainmodel/src/model.py at line 56
    [7.1901][7.1901:2054]()
    custom_objects = {"asinh": tf.math.asinh}
    with keras.utils.custom_object_scope(custom_objects):
    return keras.models.clone_model(source)
    [7.1901]
    custom_objects = {"asinh": tf.math.asinh}
    with keras.utils.custom_object_scope(custom_objects):
    return keras.models.clone_model(source)
  • replacement in trainmodel/src/geology.py at line 11
    [7.406][7.406:828]()
    'fine_sediment': 1500.,
    'voarse_sediment': 1500.,
    'sediment': 1500.,
    'sedimentary': 2600.,
    'metamorphic': 2800.,
    'felsic_plutonic': 2600.,
    'felsic_volcanic': 2600.,
    'mafic_volcanic_min': 2890., # Carlson & Raskin 1984
    'mafic_volcanic_max': 3300.,
    'mantle': 3075., # derived empirically using isostatic model
    'ocean': 1026.,
    }
    [7.406]
    [7.828]
    'fine_sediment': 1500.,
    'voarse_sediment': 1500.,
    'sediment': 1500.,
    'sedimentary': 2600.,
    'metamorphic': 2800.,
    'felsic_plutonic': 2600.,
    'felsic_volcanic': 2600.,
    'mafic_volcanic_min': 2890., # Carlson & Raskin 1984
    'mafic_volcanic_max': 3300.,
    'mantle': 3075., # derived empirically using isostatic model
    'ocean': 1026.,
    }
  • replacement in trainmodel/src/geology.py at line 26
    [7.855][7.855:1406]()
    fraction_of_lifetime = saved.crust_layers['age'] / 7889537440886400.0
    mafic_density = material_density['mafic_volcanic_min'] + (material_density['mafic_volcanic_max'] - material_density['mafic_volcanic_min']) * fraction_of_lifetime
    total_thickness = (saved.crust_layers['mafic_volcanic'] + saved.crust_layers['mafic_plutonic']) / mafic_density
    for rocktype, density in material_density.items():
    if rocktype in saved.crust_layers:
    total_thickness += saved.crust_layers[rocktype] / density
    return total_thickness
    [7.855]
    [7.1406]
    fraction_of_lifetime = saved.crust_layers['age'] / 7889537440886400.0
    mafic_density = material_density['mafic_volcanic_min'] + (
    material_density['mafic_volcanic_max'] -
    material_density['mafic_volcanic_min']) * fraction_of_lifetime
    total_thickness = (saved.crust_layers['mafic_volcanic'] +
    saved.crust_layers['mafic_plutonic']) / mafic_density
    for rocktype, density in material_density.items():
    if rocktype in saved.crust_layers:
    total_thickness += saved.crust_layers[rocktype] / density
    return total_thickness
  • replacement in trainmodel/src/geology.py at line 39
    [7.1442][7.1442:1559]()
    thickness = get_thickness(saved)
    return thickness - saved.crust_layers['total'] / material_density['mantle']
    [7.1442]
    thickness = get_thickness(saved)
    return thickness - saved.crust_layers['total'] / material_density['mantle']
  • replacement in trainmodel/src/drawmap.py at line 16
    [7.12][7.98:201](),[7.553][7.98:201](),[7.98][7.98:201]()
    window = sdl2.ext.Window("Training neural network: memorizing fictional world map", size=(1024,512))
    [7.12]
    [7.202]
    window = sdl2.ext.Window(
    "Training neural network: memorizing fictional world map",
    size=(1024, 512))
  • replacement in trainmodel/src/drawmap.py at line 27
    [7.252][7.34:82](),[7.82][7.13:41](),[7.41][7.1723:1853](),[7.1853][7.262:402](),[7.262][7.262:402](),[7.402][7.252:408](),[7.864][7.252:408](),[7.252][7.252:408](),[7.408][7.0:53](),[7.53][7.23:106](),[7.106][7.1854:1969](),[7.1969][6.77:226](),[6.226][7.106:320](),[7.2093][7.106:320](),[7.106][7.106:320](),[7.320][6.227:325](),[6.325][7.397:459](),[7.397][7.397:459](),[7.135][7.408:431](),[7.459][7.408:431](),[7.408][7.408:431]()
    if time.monotonic() - last_rendered > 15:
    outputs = m(inputs)
    image = tensor_to_surface(tf.math.multiply(255, colourize_heightmap(tf.reshape(outputs, (512, 1024, outputs.shape[1])))))
    sdl2.SDL_BlitSurface(image, None, windowsurface, None)
    last_rendered = time.monotonic()
    sdl2.SDL_FreeSurface(image)
    events = sdl2.ext.get_events()
    for event in events:
    if event.type == sdl2.SDL_QUIT:
    running = False
    break
    elif event.type == sdl2.SDL_MOUSEBUTTONUP:
    point = list(inputs[event.button.y * 1024 + event.button.x].numpy())
    solid_angle = landmass_steradians(tf.reshape(outputs, (512,1024,1)), event.button.x, event.button.y)
    print('Clicked land mass: %s square Km | %s square miles' % (solid_angle * planet_radius_km**2, solid_angle * planet_radius_miles**2))
    if last_clicked != None:
    dug = math.sqrt(sum(map((lambda p: (p[0]-p[1])**2), zip(last_clicked, point))))
    arc = math.acos(1 - dug**2 / 2) # cosine rule, a == b == 1
    print('%s Km | %s miles' % (arc * planet_radius_km, arc * planet_radius_miles))
    print(point)
    last_clicked = point
    window.refresh()
    [7.252]
    [7.431]
    if time.monotonic() - last_rendered > 15:
    outputs = m(inputs)
    image = tensor_to_surface(
    tf.math.multiply(
    255,
    colourize_heightmap(
    tf.reshape(outputs, (512, 1024, outputs.shape[1])))))
    sdl2.SDL_BlitSurface(image, None, windowsurface, None)
    last_rendered = time.monotonic()
    sdl2.SDL_FreeSurface(image)
    events = sdl2.ext.get_events()
    for event in events:
    if event.type == sdl2.SDL_QUIT:
    running = False
    break
    elif event.type == sdl2.SDL_MOUSEBUTTONUP:
    point = list(inputs[event.button.y * 1024 + event.button.x].numpy())
    solid_angle = landmass_steradians(tf.reshape(outputs, (512, 1024, 1)),
    event.button.x, event.button.y)
    print('Clicked land mass: %s square Km | %s square miles' %
    (solid_angle * planet_radius_km**2,
    solid_angle * planet_radius_miles**2))
    if last_clicked != None:
    dug = math.sqrt(
    sum(map((lambda p: (p[0] - p[1])**2), zip(last_clicked, point))))
    arc = math.acos(1 - dug**2 / 2) # cosine rule, a == b == 1
    print('%s Km | %s miles' %
    (arc * planet_radius_km, arc * planet_radius_miles))
    print(point)
    last_clicked = point
    window.refresh()
  • edit in trainmodel/src/drawmap.py at line 60
    [7.278]
    [7.120]
  • replacement in trainmodel/src/drawmap.py at line 62
    [7.163][7.163:392]()
    n = numpy.zeros((height, width, 3), numpy.float64)
    helpers.equirectangular(ctypes.cast(ctypes.c_voidp(n.ctypes.data), ctypes.POINTER(ctypes.c_double)), ctypes.c_int(width), ctypes.c_int(height))
    return tf.constant(n)
    [7.163]
    [7.90]
    n = numpy.zeros((height, width, 3), numpy.float64)
    helpers.equirectangular(
    ctypes.cast(ctypes.c_voidp(n.ctypes.data),
    ctypes.POINTER(ctypes.c_double)), ctypes.c_int(width),
    ctypes.c_int(height))
    return tf.constant(n)
  • edit in trainmodel/src/drawmap.py at line 69
    [7.91]
    [7.460]
  • replacement in trainmodel/src/drawmap.py at line 71
    [7.491][7.491:516](),[7.516][7.900:1089]()
    shape = source.shape
    source = tf.cast(source, tf.uint8).numpy()
    return helpers.render_tensor(ctypes.c_void_p(source.ctypes.data), ctypes.c_int(shape[1]), ctypes.c_int(shape[0]), ctypes.c_int(shape[2]))
    [7.491]
    [7.913]
    shape = source.shape
    source = tf.cast(source, tf.uint8).numpy()
    return helpers.render_tensor(ctypes.c_void_p(source.ctypes.data),
    ctypes.c_int(shape[1]), ctypes.c_int(shape[0]),
    ctypes.c_int(shape[2]))
  • edit in trainmodel/src/drawmap.py at line 77
    [7.914]
    [7.1478]
  • replacement in trainmodel/src/drawmap.py at line 79
    [7.1511][7.1511:1908]()
    shape = source.shape
    n = numpy.zeros((shape[0],shape[1],3), numpy.float64)
    source = tf.cast(source, tf.float64).numpy()
    helpers.colourize_heightmap(ctypes.cast(ctypes.c_voidp(n.ctypes.data), ctypes.POINTER(ctypes.c_double)), ctypes.cast(ctypes.c_voidp(source.ctypes.data), ctypes.POINTER(ctypes.c_double)), ctypes.c_int(shape[1]), ctypes.c_int(shape[0]))
    return tf.constant(n)
    [7.1511]
    [7.2094]
    shape = source.shape
    n = numpy.zeros((shape[0], shape[1], 3), numpy.float64)
    source = tf.cast(source, tf.float64).numpy()
    helpers.colourize_heightmap(
    ctypes.cast(ctypes.c_voidp(n.ctypes.data),
    ctypes.POINTER(ctypes.c_double)),
    ctypes.cast(ctypes.c_voidp(source.ctypes.data),
    ctypes.POINTER(ctypes.c_double)), ctypes.c_int(shape[1]),
    ctypes.c_int(shape[0]))
    return tf.constant(n)
  • replacement in trainmodel/src/drawmap.py at line 92
    [7.2134][7.2134:2411]()
    shape = source.shape
    source = tf.cast(source, tf.float64).numpy()
    return helpers.landmass_steradians(ctypes.cast(ctypes.c_voidp(source.ctypes.data), ctypes.POINTER(ctypes.c_double)), ctypes.c_int(shape[1]), ctypes.c_int(shape[0]), ctypes.c_int(x), ctypes.c_int(y))
    [7.2134]
    shape = source.shape
    source = tf.cast(source, tf.float64).numpy()
    return helpers.landmass_steradians(
    ctypes.cast(ctypes.c_voidp(source.ctypes.data),
    ctypes.POINTER(ctypes.c_double)), ctypes.c_int(shape[1]),
    ctypes.c_int(shape[0]), ctypes.c_int(x), ctypes.c_int(y))
  • edit in trainmodel/src/__main__.py at line 9
    [7.44]
    [7.29]
  • replacement in trainmodel/src/__main__.py at line 12
    [7.66][7.51:103](),[7.80][7.51:103](),[7.51][7.51:103](),[7.103][7.81:129](),[7.129][7.67:146](),[7.146][4.29:83]()
    source = simsave.SimResult(open(filename, 'r'))
    training_data = model.training_data(source)
    m.fit(x=training_data[0], y=training_data[1], batch_size=100, epochs=5000)
    tfjs.converters.save_keras_model(m, 'tfjs_model')
    [7.66]
    [7.128]
    source = simsave.SimResult(open(filename, 'r'))
    training_data = model.training_data(source)
    m.fit(x=training_data[0], y=training_data[1], batch_size=100, epochs=5000)
    tfjs.converters.save_keras_model(m, 'tfjs_model')
  • replacement in trainmodel/src/__main__.py at line 17
    [7.129][7.25:110](),[7.110][7.147:199](),[7.199][7.1909:1985](),[7.156][7.222:335](),[7.1985][7.222:335](),[7.222][7.222:335]()
    inputs = tf.reshape(drawmap.inputs_equirectangular(2048,1024), (2048 * 1024, 3))
    outputs = tf.reshape(m(inputs), (1024,2048, 1))
    outputs = tf.cast(drawmap.colourize_heightmap(outputs) * 255, tf.uint8)
    outputs = tf.io.encode_png(outputs).numpy()
    f = open("map.png", 'wb')
    f.write(outputs)
    f.close()
    [7.129]
    [7.335]
    inputs = tf.reshape(drawmap.inputs_equirectangular(2048, 1024),
    (2048 * 1024, 3))
    outputs = tf.reshape(m(inputs), (1024, 2048, 1))
    outputs = tf.cast(drawmap.colourize_heightmap(outputs) * 255, tf.uint8)
    outputs = tf.io.encode_png(outputs).numpy()
    f = open("map.png", 'wb')
    f.write(outputs)
    f.close()
  • replacement in trainmodel/src/__main__.py at line 28
    [7.151][7.240:327](),[7.327][7.187:229](),[7.229][7.376:390](),[7.376][7.376:390](),[7.390][7.200:281](),[7.281][7.230:252](),[7.508][7.230:252](),[7.230][7.230:252](),[7.252][7.282:301](),[7.301][7.270:291](),[7.534][7.270:291](),[7.270][7.270:291]()
    m = model.model()
    m.compile(
    optimizer=keras.optimizers.RMSprop(),
    loss=model.shore_focused_loss
    )
    bg_thread = threading.Thread(target=train, args=(m, sys.argv[1]), kwargs={})
    bg_thread.start()
    drawmap.run(m)
    bg_thread.join()
    [7.151]
    [7.291]
    m = model.model()
    m.compile(optimizer=keras.optimizers.RMSprop(),
    loss=model.shore_focused_loss)
    bg_thread = threading.Thread(target=train, args=(m, sys.argv[1]), kwargs={})
    bg_thread.start()
    drawmap.run(m)
    bg_thread.join()
  • replacement in trainmodel/src/__main__.py at line 36
    [7.297][7.297:366](),[7.44][7.45:46](),[7.366][7.45:46](),[7.45][7.45:46]()
    print("Expecting filename of tectonic.js save", file=sys.stderr)
    [7.297]
    print("Expecting filename of tectonic.js save", file=sys.stderr)