Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion keras/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@ def deserialize(obj):

# instantiate optimizer
training_config = f.attrs.get('training_config')
if training_config is None:
if training_config is None or ('classify' in custom_objects and custom_objects['classify']):
custom_objects.pop('classify', None)
warnings.warn('No training configuration found in save file: '
'the model was *not* compiled. Compile it manually.')
f.close()
Expand Down
7 changes: 7 additions & 0 deletions keras/utils/layer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ def layer_from_config(config, custom_objects=None):
if custom_objects:
get_custom_objects().update(custom_objects)

# New behaviour
if custom_objects and 'layer_class' in custom_objects:
layer_class = custom_objects['layer_class']
# Remove layer class from custom_objects as it's not needed anymore
custom_objects.pop('layer_class', None)
return layer_class.from_config(config['config'], custom_objects=custom_objects)

class_name = config['class_name']

if class_name == 'Sequential':
Expand Down