Last active
April 3, 2017 11:33
-
-
Save dieuwkehupkes/6c2d861832a5015b739ce503ec3e11ad to your computer and use it in GitHub Desktop.
demonstrate fail to load with multiple output metrics in dictionary
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
keras_bug.py << buffers | |
from keras.layers import Input, Dense | |
from keras.models import Model, load_model | |
import numpy as np | |
input_layer = Input(shape=(5,)) | |
hidden = Dense(5)(input_layer) | |
output1 = Dense(1, name='output1')(hidden) | |
output2 = Dense(1, name='output2')(hidden) | |
m = Model(inputs=input_layer, outputs=[output1, output2]) | |
metrics = {'output1': ['mse', 'binary_accuracy'], 'output2': ['mse', 'binary_accuracy']} | |
loss = {'output1': 'mse', 'output2': 'mse'} | |
m.compile(loss=loss, optimizer='sgd', metrics=metrics) | |
# assure that model is working | |
X = np.array([[1,1,1,1,1]]) | |
m.predict(X) | |
# save model | |
m.save('saved_model.h5') | |
model = load_model('saved_model.h5') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment