How to use the elephas.java.adapter.retrieve_keras_weights function in elephas

To help you get started, we’ve selected a few elephas examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maxpumperla / elephas / examples / basic_import.py View on Github external
model = Sequential()
model.add(Dense(units=64, activation='relu', input_dim=100))
model.add(Dense(units=10, activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='sgd', metrics=['accuracy'])

model.save('test.h5')


kmi = java_classes.KerasModelImport
file = java_classes.File("test.h5")

java_model = kmi.importKerasSequentialModelAndWeights(file.absolutePath)

weights = adapter.retrieve_keras_weights(java_model)
model.set_weights(weights)
github maxpumperla / elephas / elephas / dl4j.py View on Github external
def get_keras_model(self):
        model = self.master_network
        java_model = self.java_spark_model.getNetwork()
        weights = adapter.retrieve_keras_weights(java_model)
        model.set_weights(weights)
        return model
github maxpumperla / elephas / elephas / dl4j.py View on Github external
def get_keras_model(self):
        model = self.master_network
        java_model = self.java_spark_model.getNetwork()
        weights = adapter.retrieve_keras_weights(java_model)
        model.set_weights(weights)
        return model