ListMapper does not support model.save
Closed this issue · 1 comments
pedro-r-marques commented
Got a stack trace when attempting to save model.
~/src/keras-list-mapper/keras_list_mapper/keras_list_mapper.py in __call__(self, inputs, *args, **kwargs)
85 K.is_keras_tensor(t) for t in inputs_list)
86 if not in_functional_construction_mode:
---> 87 return super().__call__(inputs)
88
89 inner_inputs = []
~/src/keras-list-mapper/.venv/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in __call__(self, *args, **kwargs)
983 # signature
984 # (5) False (treating the layer as if it's in inference)
--> 985 args, kwargs, training_mode = self._set_training_mode(
986 args, kwargs, call_context)
987
~/src/keras-list-mapper/.venv/lib/python3.7/site-packages/tensorflow/python/autograph/impl/api.py in wrapper(*args, **kwargs)
300 setattr(entity.__func__, 'autograph_info__', extras)
301 else:
--> 302 setattr(entity, 'autograph_info__', extras)
303 return entity
304
~/src/keras-list-mapper/keras_list_mapper/keras_list_mapper.py in call(self, inputs, *args, **kwargs)
157 row_lengths = rt.row_lengths()
158 max_seq_len = input_rt_shape[1]
--> 159 for i in tf.range(max_seq_len):
160 indices = tf.where(tf.math.less(i, row_lengths))
161 xcol = tf.fill([tf.shape(indices)[0]], i)
~/src/keras-list-mapper/.venv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in __iter__(self)
501 # Default: V1-style Graph execution.
502 self._disallow_in_graph_mode("iterating over `tf.Tensor`")
--> 503
504 def __iter__(self):
505 if not context.executing_eagerly():
~/src/keras-list-mapper/.venv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in _disallow_iteration(self)
492 # Default: V1-style Graph execution.
493 self._disallow_in_graph_mode("using a `tf.Tensor` as a Python `bool`")
--> 494
495 def _disallow_iteration(self):
496 if ag_ctx.control_status_ctx().status == ag_ctx.Status.DISABLED:
~/src/keras-list-mapper/.venv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py in _disallow_when_autograph_disabled(self, task)
467 "Tensor._shape cannot be assigned, use Tensor.set_shape instead.")
468
--> 469 def _disallow_when_autograph_disabled(self, task):
470 raise errors.OperatorNotAllowedInGraphError(
471 "{} is not allowed: AutoGraph is disabled in this function."
OperatorNotAllowedInGraphError: iterating over `tf.Tensor` is not allowed: AutoGraph is disabled in this function. Try decorating it directly with @tf.function.
pedro-r-marques commented
Saving of models with layers that return ragged tensors seems to not be currently supported tensorflow/tensorflow#45797