7ML3OFE732OG2ZBZWETBMMZTATOAJGOMNUEIV4GEJI56JX3P7NJQC
SJHJS463IU7LHBM4C6FO2PJSLZLT7LCN26W2D3V2NIQEQKA4HCLAC
5AMZXFS5GBD6DS64Q5RTY55U7LQDMDW776UHZK4HQPPXWSMO3MAQC
FL3C6ERZKQLTMETYALWADCLGP2CXFEHTDFE2PDXHTSSSIY452PUAC
ZM2EMAZOPZDZ2VUIE6NGAXS2OM7MYNWTMHIKM7KPIKSYXXR4D4CQC
ROQCAPZJPLENWBMHRK7DNH3CIMZRHPBMVBBKT7NQXRIFHEDZ5JHQC
IGYI5RVVRFQUQBDH6KQ2MH6ADCZ455Z634BRXKLCEYFF4ZKQ3TMQC
6AXPZL5PQMW5P6BPRTGWO3AOWAU5OC33UYBY3TVOHUVQXCRVVTPQC
X5U7KRUIQBF7CQ2F2WRTQJ64PXUXGP3AQYWBRKKH3VMUYKJ4LXDQC
bg_thread = threading.Thread(target=train, args=(sys.argv[1],), kwargs={})
m = model.model()
m.compile(
optimizer=keras.optimizers.RMSprop(),
loss=keras.losses.MeanSquaredError()
)
monitor = model.Monitor(m)
bg_thread = threading.Thread(target=train, args=(monitor, sys.argv[1]), kwargs={})
test_tensor = tf.math.scalar_mul(255, tf.keras.activations.sigmoid(inputs_equirectangular(1024, 512)))
image = tensor_to_surface(test_tensor)
sdl2.SDL_BlitSurface(image, None, windowsurface, None)
inputs = tf.reshape(inputs_equirectangular(1024, 512), (1024 * 512, 3))
return helpers.render_tensor(ctypes.c_void_p(tf.cast(source, tf.uint8).numpy().ctypes.data), ctypes.c_int(shape[1]), ctypes.c_int(shape[0]), ctypes.c_int(shape[2]))
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]))
import tensorflow as tf
from tensorflow import keras
import threading
def model():
inputs = keras.Input(shape=(3,))
layer = keras.layers.Dense(9, activation=tf.math.asinh)(inputs)
layer = keras.layers.Dense(24, activation=tf.math.asinh)(layer)
layer = keras.layers.Dense(240, activation=tf.math.asinh)(layer)
layer = keras.layers.Dense(240, activation=tf.math.asinh)(layer)
layer = keras.layers.Dense(24, activation=tf.math.asinh)(layer)
outputs = keras.layers.Dense(1, activation=keras.activations.sigmoid)(layer)
return keras.Model(inputs=inputs, outputs=outputs, name="geology_model")
def training_data(simresult):
return (simresult.vertices, tf.math.multiply(1/700000000, simresult.crust_layers['total']))
def clone_my_model(source):
custom_objects = {"asinh": tf.math.asinh}
with keras.utils.custom_object_scope(custom_objects):
return keras.models.clone_model(source)
class Monitor(keras.callbacks.Callback):
def __init__(self, target):
self.lock = threading.Lock()
self.target = target
self.stable = clone_my_model(target)
def on_epoch_end(self, epoch, logs=None):
self.lock.acquire()
self.stable.set_weights(self.target.get_weights())
self.lock.release()
def snapshot(self):
self.lock.acquire()
result = self.stable
self.lock.release()
return result