Reputation: 2154
I faced with problem when I try to train pre-trained model loaded from json config + weights file.
I use following code (simplified):
from keras.utils.layer_utils import layer_from_config
with open("config.json", "rb") as f:
config = json.loads(f.read())
model = layer_from_config(config)
model.load_weights("weights.net")
history = model.fit(batch, target, verbose=1,
validation_data=(test_batch, test_target), shuffle=True)
And I got following exception:
theano.gof.fg.MissingInputError: ("An input of the graph, used to compute DimShuffle{x,x}(keras_learning_phase), was not provided and not given a value.Use the Theano flag exception_verbosity='high',for more information on this error.", keras_learning_phase)
I think it makes sense since I have dropout layers in model so it should know current learning phase. How can I set learning phase to 'train'? Or may be different problem here?
Thanks in advance!
Upvotes: 1
Views: 3040
Reputation: 2154
Let me answer to this question by myself.
This issue is related only to keras 1.0.0 version and it was fixed in 1.0.2. So code snippet above is perfectly work on newer version of keras, no need to explicitly set learning phase.
More details in github issue tread.
Upvotes: 1