Skip to content

Commit

Permalink
Fix json serialization in Lambda layer (#3012)
Browse files Browse the repository at this point in the history
Fix #2582
Fix #3001
  • Loading branch information
henry0312 authored and fchollet committed Jun 18, 2016
1 parent a13a35f commit e37df7c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions keras/layers/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,9 @@ def get_config(self):

if isinstance(self._output_shape, python_types.LambdaType):
if py3:
output_shape = marshal.dumps(self._output_shape.__code__)
output_shape = marshal.dumps(self._output_shape.__code__).decode('raw_unicode_escape')
else:
output_shape = marshal.dumps(self._output_shape.func_code)
output_shape = marshal.dumps(self._output_shape.func_code).decode('raw_unicode_escape')
output_shape_type = 'lambda'
elif callable(self._output_shape):
output_shape = self._output_shape.__name__
Expand Down Expand Up @@ -494,7 +494,7 @@ def from_config(cls, config):
if output_shape_type == 'function':
output_shape = globals()[config['output_shape']]
elif output_shape_type == 'lambda':
output_shape = marshal.loads(config['output_shape'])
output_shape = marshal.loads(config['output_shape'].encode('raw_unicode_escape'))
output_shape = python_types.FunctionType(output_shape, globals())
else:
output_shape = config['output_shape']
Expand Down

0 comments on commit e37df7c

Please sign in to comment.