Skip to content

Commit

Permalink
Fix JSON serialization error in TensorFlowOpLayer in Python 3.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 259397921
  • Loading branch information
omalleyt12 authored and tensorflower-gardener committed Jul 22, 2019
1 parent 3c5fb53 commit 7cc180f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tensorflow/python/keras/engine/base_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2387,6 +2387,8 @@ def __init__(self,
dtype=None):
super(TensorFlowOpLayer, self).__init__(
name=_TF_OP_LAYER_NAME_PREFIX + name, trainable=trainable, dtype=dtype)
if not isinstance(node_def, bytes):
node_def = node_def.encode('utf-8')
self.node_def = node_def_pb2.NodeDef.FromString(node_def)
self.constants = constants or {}
# Layer uses original op unless it is called on new inputs.
Expand Down Expand Up @@ -2446,7 +2448,7 @@ def _defun_call(self, inputs):
def get_config(self):
config = super(TensorFlowOpLayer, self).get_config()
config.update({
'node_def': self.node_def.SerializeToString(),
'node_def': self.node_def.SerializeToString().decode('utf-8'),
'constants': {
i: backend.get_value(c) for i, c in self.constants.items()
}
Expand Down

0 comments on commit 7cc180f

Please sign in to comment.