Skip to content

Instantly share code, notes, and snippets.

@matpalm
Created September 30, 2019 03:27
Show Gist options
  • Save matpalm/779c2c67d5ec195845ae2ab01570d883 to your computer and use it in GitHub Desktop.
Save matpalm/779c2c67d5ec195845ae2ab01570d883 to your computer and use it in GitHub Desktop.
1/Unknown - 0s 14ms/step
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-2-231b4cfe798d> in <module>()
19 dataset = dataset.batch(4).prefetch(1)
20
---> 21 model.fit(dataset)
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, max_queue_size, workers, use_multiprocessing, **kwargs)
732 max_queue_size=max_queue_size,
733 workers=workers,
--> 734 use_multiprocessing=use_multiprocessing)
735
736 def evaluate(self,
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_v2.py in fit(self, model, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_freq, **kwargs)
322 mode=ModeKeys.TRAIN,
323 training_context=training_context,
--> 324 total_epochs=epochs)
325 cbks.make_logs(model, epoch_logs, training_result, ModeKeys.TRAIN)
326
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_v2.py in run_one_epoch(model, iterator, execution_function, dataset_size, batch_size, strategy, steps_per_epoch, num_samples, mode, training_context, total_epochs)
121 step=step, mode=mode, size=current_batch_size) as batch_logs:
122 try:
--> 123 batch_outs = execution_function(iterator)
124 except (StopIteration, errors.OutOfRangeError):
125 # TODO(kaftan): File bug about tf function and errors.OutOfRangeError?
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_v2_utils.py in execution_function(input_fn)
84 # `numpy` translates Tensors to values in Eager mode.
85 return nest.map_structure(_non_none_constant_value,
---> 86 distributed_function(input_fn))
87
88 return execution_function
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/eager/def_function.py in __call__(self, *args, **kwds)
425 # This is the first call of __call__, so we have to initialize.
426 initializer_map = object_identity.ObjectIdentityDictionary()
--> 427 self._initialize(args, kwds, add_initializers_to=initializer_map)
428 if self._created_variables:
429 try:
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/eager/def_function.py in _initialize(self, args, kwds, add_initializers_to)
368 self._concrete_stateful_fn = (
369 self._stateful_fn._get_concrete_function_internal_garbage_collected( # pylint: disable=protected-access
--> 370 *args, **kwds))
371
372 def invalid_creator_scope(*unused_args, **unused_kwds):
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py in _get_concrete_function_internal_garbage_collected(self, *args, **kwargs)
1845 if self.input_signature:
1846 args, kwargs = None, None
-> 1847 graph_function, _, _ = self._maybe_define_function(args, kwargs)
1848 return graph_function
1849
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py in _maybe_define_function(self, args, kwargs)
2145 graph_function = self._function_cache.primary.get(cache_key, None)
2146 if graph_function is None:
-> 2147 graph_function = self._create_graph_function(args, kwargs)
2148 self._function_cache.primary[cache_key] = graph_function
2149 return graph_function, args, kwargs
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/eager/function.py in _create_graph_function(self, args, kwargs, override_flat_arg_shapes)
2036 arg_names=arg_names,
2037 override_flat_arg_shapes=override_flat_arg_shapes,
-> 2038 capture_by_value=self._capture_by_value),
2039 self._function_attributes,
2040 # Tell the ConcreteFunction to clean up its graph once it goes out of
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/framework/func_graph.py in func_graph_from_py_func(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, override_flat_arg_shapes)
913 converted_func)
914
--> 915 func_outputs = python_func(*func_args, **func_kwargs)
916
917 # invariant: `func_outputs` contains only Tensors, CompositeTensors,
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/eager/def_function.py in wrapped_fn(*args, **kwds)
318 # __wrapped__ allows AutoGraph to swap in a converted function. We give
319 # the function a weak reference to itself to avoid a reference cycle.
--> 320 return weak_wrapped_fn().__wrapped__(*args, **kwds)
321 weak_wrapped_fn = weakref.ref(wrapped_fn)
322
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_v2_utils.py in distributed_function(input_iterator)
64 """A single step of the distributed execution across replicas."""
65 x, y, sample_weights = _prepare_feed_values(
---> 66 model, input_iterator, mode)
67 # Call `Model.{train,test,predict}_on_batch` on every replica passing
68 # PerReplicas as arguments. On every replica inside this call, each
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_v2_utils.py in _prepare_feed_values(model, inputs, mode)
110 for inputs will always be wrapped in lists.
111 """
--> 112 inputs, targets, sample_weights = _get_input_from_iterator(inputs)
113
114 # When the inputs are dict, then we want to flatten it in the same order as
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/training_v2_utils.py in _get_input_from_iterator(iterator)
147 # Validate that all the elements in x and y are of the same type and shape.
148 dist_utils.validate_distributed_dataset_inputs(
--> 149 distribution_strategy_context.get_strategy(), x, y, sample_weights)
150 return x, y, sample_weights
151
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/keras/distribute/distributed_training_utils.py in validate_distributed_dataset_inputs(distribution_strategy, x, y, sample_weights)
306 # If each element of x and y are not tensors, we cannot standardize and
307 # validate the input and targets.
--> 308 x_values_list = validate_per_replica_inputs(distribution_strategy, x)
309
310 if y is not None:
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/keras/distribute/distributed_training_utils.py in validate_per_replica_inputs(distribution_strategy, x)
354 if not context.executing_eagerly():
355 # Validate that the shape and dtype of all the elements in x are the same.
--> 356 validate_all_tensor_shapes(x, x_values)
357 validate_all_tensor_types(x, x_values)
358
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/keras/distribute/distributed_training_utils.py in validate_all_tensor_shapes(x, x_values)
371 def validate_all_tensor_shapes(x, x_values):
372 # Validate that the shape of all the elements in x have the same shape
--> 373 x_shape = x_values[0].shape.as_list()
374 for i in range(1, len(x_values)):
375 if x_shape != x_values[i].shape.as_list():
/usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow_core/python/framework/tensor_shape.py in as_list(self)
1169 """
1170 if self._dims is None:
-> 1171 raise ValueError("as_list() is not defined on an unknown TensorShape.")
1172 return [dim.value for dim in self._dims]
1173
ValueError: as_list() is not defined on an unknown TensorShape.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment