**Can you please look into the error and let me know what changes have to be done?I am unable to solve the error.
I have attached the collab link at last for reference.
Thank you.**
ValueError Traceback (most recent call last)
in ()
13 os.makedirs('ReconstructedImages/%s'%identities[i].split('.')[0])
14 ran = RAN(identities[i].split('.')[0])
---> 15 ran.train(epochs=30000, batch_size=256, save_interval=50)
10 frames
in train(self, epochs, batch_size, save_interval)
174 # Train the reconstructor
175 r_loss = self.combined.train_on_batch(img, [img,valid])
--> 176 r_loss_val= self.combined.test_on_batch(imgsVal, [imgsVal,valid])
177 TrainLoss[epoch] = r_loss[0]
178 MinValLoss = ValLoss.min()
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py in test_on_batch(self, x, y, sample_weight, reset_metrics, return_dict)
1752 user. For example: 'acc'.
1753 output_index: The index of the model output for which the metric name is
-> 1754 being added.
1755
1756 Returns:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py in call(self, *args, **kwds)
778 print(i) # Works
779 tf.compat.v1.assign(v, i) # Works
--> 780 tf.compat.v1.py_func(lambda i: l.append(i))(i) # Works
781 l.append(i) # Caution! Doesn't work.
782 ```
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py in _call(self, *args, **kwds)
821 self.b = tf.Variable(tf.zeros(10))
822
--> 823 @tf.function
824 def compute(self, x):
825 return tf.matmul(x, self.W) + self.b
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py in _initialize(self, args, kwds, add_initializers_to)
695 return concrete
696
--> 697 def get(self, instance, owner):
698 """Makes it possible to defun instance methods."""
699 del owner
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py in _get_concrete_function_internal_garbage_collected(self, *args, **kwargs)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py in _maybe_define_function(self, args, kwargs)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py in _create_graph_function(self, args, kwargs, override_flat_arg_shapes)
/usr/local/lib/python3.6/dist-packages/tensorflow/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)
984 """
985 # TODO(b/115366440): Delete this method when a custom OrderedDict is added.
--> 986 # Clearing captures using clear() leaves some cycles around.
987 while func_graph.captures:
988 func_graph.captures.popitem()
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py in wrapped_fn(*args, **kwds)
598 if not any(equal_to_signature(s) for s in seen_signatures):
599 deduplicated_concrete_functions.append(concrete_function)
--> 600 seen_signatures.append(signature)
601 return deduplicated_concrete_functions
602
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs)
971 args, names, structure=kwargs, flat_shapes=flat_shapes)
972
--> 973
974 def dismantle_func_graph(func_graph):
975 """Removes reference cycles in func_graph FuncGraph.
ValueError: in user code:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:1224 test_function *
return step_function(self, iterator)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:1215 step_function **
verbose: Verbosity mode, 0 or 1.
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:1211 run
determine which case you are in. If in a replica context,
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:2585 call_for_each_replica
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:2945 _call_for_each_replica
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:1208 run_step **
execute the generator on the main thread.
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:1177 test_step
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/compile_utils.py:204 call
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/losses.py:149 call
y_pred: The predicted values.
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/losses.py:253 call **
/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/dispatch.py:201 wrapper
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/losses.py:1195 mean_squared_error
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_math_ops.py:10399 squared_difference
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:744 _apply_op_helper
attr_value.list.shape.extend(
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py:593 _create_op_internal
containing non-tensors, while entries containing a TensorShape must
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py:3485 _create_op_internal
# need context to generate nice error messages.
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py:1975 init
TypeError: if tensor is not a Tensor,
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py:1815 _create_c_op
self._control_flow_context = ctx
ValueError: Dimensions must be equal, but are 86 and 128 for '{{node mean_squared_error_1/SquaredDifference}} = SquaredDifference[T=DT_FLOAT](functional_65/functional_61/conv2d_164/BiasAdd, IteratorGetNext:2)' with input shapes: [86,2,2,1], [128,2,2,1].
(https://colab.research.google.com/drive/1LLvXZBRYo8vIvWQo6H1U4DLNXfVbNTTF?usp=sharing).
**Can you please look into the error and let me know what changes have to be done?I am unable to solve the error.
I have attached the collab link at last for reference.
Thank you.**
ValueError Traceback (most recent call last)
in ()
13 os.makedirs('ReconstructedImages/%s'%identities[i].split('.')[0])
14 ran = RAN(identities[i].split('.')[0])
---> 15 ran.train(epochs=30000, batch_size=256, save_interval=50)
10 frames
in train(self, epochs, batch_size, save_interval)
174 # Train the reconstructor
175 r_loss = self.combined.train_on_batch(img, [img,valid])
--> 176 r_loss_val= self.combined.test_on_batch(imgsVal, [imgsVal,valid])
177 TrainLoss[epoch] = r_loss[0]
178 MinValLoss = ValLoss.min()
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py in test_on_batch(self, x, y, sample_weight, reset_metrics, return_dict)
1752 user. For example: 'acc'.
1753 output_index: The index of the model output for which the metric name is
-> 1754 being added.
1755
1756 Returns:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py in call(self, *args, **kwds)
778 print(i) # Works
779 tf.compat.v1.assign(v, i) # Works
--> 780 tf.compat.v1.py_func(lambda i: l.append(i))(i) # Works
781 l.append(i) # Caution! Doesn't work.
782 ```
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py in _call(self, *args, **kwds)
821 self.b = tf.Variable(tf.zeros(10))
822
--> 823 @tf.function
824 def compute(self, x):
825 return tf.matmul(x, self.W) + self.b
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py in _initialize(self, args, kwds, add_initializers_to)
695 return concrete
696
--> 697 def get(self, instance, owner):
698 """Makes it possible to defun instance methods."""
699 del owner
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py in _get_concrete_function_internal_garbage_collected(self, *args, **kwargs)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py in _maybe_define_function(self, args, kwargs)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/function.py in _create_graph_function(self, args, kwargs, override_flat_arg_shapes)
/usr/local/lib/python3.6/dist-packages/tensorflow/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)
984 """
985 # TODO(b/115366440): Delete this method when a custom OrderedDict is added.
--> 986 # Clearing captures using clear() leaves some cycles around.
987 while func_graph.captures:
988 func_graph.captures.popitem()
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/def_function.py in wrapped_fn(*args, **kwds)
598 if not any(equal_to_signature(s) for s in seen_signatures):
599 deduplicated_concrete_functions.append(concrete_function)
--> 600 seen_signatures.append(signature)
601 return deduplicated_concrete_functions
602
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py in wrapper(*args, **kwargs)
971 args, names, structure=kwargs, flat_shapes=flat_shapes)
972
--> 973
974 def dismantle_func_graph(func_graph):
975 """Removes reference cycles in func_graph FuncGraph.
ValueError: in user code:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:1224 test_function *
return step_function(self, iterator)
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:1215 step_function **
verbose: Verbosity mode, 0 or 1.
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:1211 run
determine which case you are in. If in a replica context,
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:2585 call_for_each_replica
/usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:2945 _call_for_each_replica
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:1208 run_step **
execute the generator on the main thread.
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training.py:1177 test_step
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/compile_utils.py:204 call
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/losses.py:149 call
y_pred: The predicted values.
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/losses.py:253 call **
/usr/local/lib/python3.6/dist-packages/tensorflow/python/util/dispatch.py:201 wrapper
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/losses.py:1195 mean_squared_error
/usr/local/lib/python3.6/dist-packages/tensorflow/python/ops/gen_math_ops.py:10399 squared_difference
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/op_def_library.py:744 _apply_op_helper
attr_value.list.shape.extend(
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/func_graph.py:593 _create_op_internal
containing non-tensors, while entries containing a
TensorShapemust/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py:3485 _create_op_internal
# need context to generate nice error messages.
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py:1975 init
TypeError: if tensor is not a Tensor,
/usr/local/lib/python3.6/dist-packages/tensorflow/python/framework/ops.py:1815 _create_c_op
self._control_flow_context = ctx
ValueError: Dimensions must be equal, but are 86 and 128 for '{{node mean_squared_error_1/SquaredDifference}} = SquaredDifference[T=DT_FLOAT](functional_65/functional_61/conv2d_164/BiasAdd, IteratorGetNext:2)' with input shapes: [86,2,2,1], [128,2,2,1].
(https://colab.research.google.com/drive/1LLvXZBRYo8vIvWQo6H1U4DLNXfVbNTTF?usp=sharing).