Недавно я добавил новую функцию в свою реализацию yolov3 , которая в настоящее время модели загружается непосредственно из файлов Dar kNet cfg для удобства, я тестировал код с конфигурацией yolov3, а также с конфигурацией yolov4, они оба работают нормально, за исключением обучения v4. Вскоре после начала обучения у меня появляется ошибка несоответствия форм, и я буду очень благодарен, если кто-нибудь поможет мне избавиться от ошибки и наконец завершить мой проект. Пожалуйста, дайте мне знать в комментариях, и я предоставлю вам любые ресурсы, которые вам понадобятся, чтобы помочь мне с решением проблемы, и заранее спасибо ...
Это то, что я запускаю, чтобы воспроизвести :
if __name__ == '__main__':
tr = Trainer((608, 608, 3),
'../Config/yolo4.cfg',
'../Config/beverly_hills.txt',
1344, 756, score_threshold=0.1,
train_tf_record='../Data/TFRecords/beverly_hills_train.tfrecord',
valid_tf_record='../Data/TFRecords/beverly_hills_test.tfrecord')
tr.train(
100,
8,
1e-3,
dataset_name='beverly_hills',
merge_evaluation=False,
n_epoch_eval=10,
clear_outputs=True
)
L
ссылки на нужные вам файлы:
Вот сообщение об ошибке:
Traceback (most recent call last):
File "trainer.py", line 629, in <module>
clear_outputs=True
File "../Helpers/utils.py", line 62, in wrapper
result = func(*args, **kwargs)
File "trainer.py", line 490, in train
validation_data=valid_dataset,
File "/root/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 108, in _method_wrapper
return method(self, *args, **kwargs)
File "/root/.local/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py", line 1090, in fit
tmp_logs = train_function(iterator)
File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 766, in __call__
result = self._call(*args, **kwds)
File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py", line 826, in _call
return self._stateless_fn(*args, **kwds)
File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 2811, in __call__
return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access
File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 1838, in _filtered_call
cancellation_manager=cancellation_manager)
File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 1914, in _call_flat
ctx, args, cancellation_manager=cancellation_manager))
File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/function.py", line 549, in call
ctx=ctx)
File "/root/.local/lib/python3.6/site-packages/tensorflow/python/eager/execute.py", line 60, in quick_execute
inputs, attrs, num_outputs)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [4,76,76,3,1] vs. [4,19,19,3,1]
[[node yolo_loss/logistic_loss/mul (defined at ../Helpers/utils.py:260) ]] [Op:__inference_train_function_38735]
Errors may have originated from an input operation.
Input Source operations connected to node yolo_loss/logistic_loss/mul:
yolo_loss/split_1 (defined at ../Helpers/utils.py:222)
yolo_loss/split (defined at ../Helpers/utils.py:196)
Function call stack:
train_function
И когда я меняю batch_size на 8 вместо 4, ошибка превращается в следующее (источник ошибки меняется):
Traceback (most recent call last):
File "/Users/emadboctor/Desktop/Code/yolov3-keras-tf2/Main/trainer.py", line 693, in <module>
clear_outputs=True,
File "/Users/emadboctor/Desktop/Code/yolov3-keras-tf2/Helpers/utils.py", line 62, in wrapper
result = func(*args, **kwargs)
File "/Users/emadboctor/Desktop/Code/yolov3-keras-tf2/Main/trainer.py", line 526, in train
validation_data=valid_dataset,
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 66, in _method_wrapper
return method(self, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py", line 848, in fit
tmp_logs = train_function(iterator)
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 580, in __call__
result = self._call(*args, **kwds)
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/eager/def_function.py", line 644, in _call
return self._stateless_fn(*args, **kwds)
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 2420, in __call__
return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1665, in _filtered_call
self.captured_inputs)
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 1746, in _call_flat
ctx, args, cancellation_manager=cancellation_manager))
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/eager/function.py", line 598, in call
ctx=ctx)
File "/usr/local/lib/python3.7/site-packages/tensorflow/python/eager/execute.py", line 60, in quick_execute
inputs, attrs, num_outputs)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [8,13,13,3,2] vs. [8,52,52,3,2]
[[node gradient_tape/yolo_loss/sub_5/BroadcastGradientArgs (defined at Users/emadboctor/Desktop/Code/yolov3-keras-tf2/Main/trainer.py:526) ]] [Op:__inference_train_function_42744]
Function call stack:
train_function