Add tiny yolo model body, but cannot retrain #93
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey,
I am trying to retrain tiny YOLO to predict traffic signs using gtsdb. I have finished the tiny YOLO body, but when I followed the instructions to retrain the model, I got "Incompatible shapes" in yolo_loss. Here is the command to replicate the issue. And the npz data file is shared here, and the class file is shared here. Note, there is loads of code duplication right now, but after debugging I will clean up.
retrain_tiny_yolo.py --data_path "my_dataset.npz" --classes_path "gtsdb_classes.txt"
Train on 666 samples, validate on 75 samples
Epoch 1/5
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1323, in _do_call
return fn(*args)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1302, in _run_fn
status, run_metadata)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/errors_impl.py", line 473, in exit
c_api.TF_GetCode(self.status.status))
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [32,13,13,5,1] vs. [32,6,6,5,1]
[[Node: yolo_loss/mul_8 = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](yolo_loss/mul_7, yolo_loss/Square_2)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "retrain_tiny_yolo.py", line 356, in
_main(args)
File "retrain_tiny_yolo.py", line 77, in _main
matching_true_boxes
File "retrain_tiny_yolo.py", line 259, in train
callbacks=[logging])
File "/usr/local/lib/python3.6/site-packages/keras/engine/training.py", line 1650, in fit
validation_steps=validation_steps)
File "/usr/local/lib/python3.6/site-packages/keras/engine/training.py", line 1213, in _fit_loop
outs = f(ins_batch)
File "/usr/local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 2352, in call
**self.session_kwargs)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 889, in run
run_metadata_ptr)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1120, in _run
feed_dict_tensor, options, run_metadata)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1317, in _do_run
options, run_metadata)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1336, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [32,13,13,5,1] vs. [32,6,6,5,1]
[[Node: yolo_loss/mul_8 = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](yolo_loss/mul_7, yolo_loss/Square_2)]]
Caused by op 'yolo_loss/mul_8', defined at:
File "retrain_tiny_yolo.py", line 356, in
_main(args)
File "retrain_tiny_yolo.py", line 68, in _main
model_body, model = create_model(anchors, class_names)
File "retrain_tiny_yolo.py", line 224, in create_model
detectors_mask_input, matching_boxes_input
File "/usr/local/lib/python3.6/site-packages/keras/engine/topology.py", line 603, in call
output = self.call(inputs, **kwargs)
File "/usr/local/lib/python3.6/site-packages/keras/layers/core.py", line 651, in call
return self.function(inputs, **arguments)
File "/Users/liangchuangu/Development/machine_learning/YAD2K/yad2k/models/keras_yolo.py", line 281, in yolo_loss
K.square(1 - pred_confidence))
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 900, in binary_op_wrapper
return func(x, y, name=name)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/math_ops.py", line 1123, in _mul_dispatch
return gen_math_ops._mul(x, y, name=name)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/ops/gen_math_ops.py", line 2821, in _mul
"Mul", x=x, y=y, name=name)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3042, in create_op
op_def=op_def)
File "/usr/local/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1521, in init
self._traceback = self._graph._extract_stack() # pylint: disable=protected-access
InvalidArgumentError (see above for traceback): Incompatible shapes: [32,13,13,5,1] vs. [32,6,6,5,1]
[[Node: yolo_loss/mul_8 = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](yolo_loss/mul_7, yolo_loss/Square_2)]]