Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erorr in reg_loss #14

Open
SalehShmali opened this issue Dec 13, 2020 · 13 comments
Open

Erorr in reg_loss #14

SalehShmali opened this issue Dec 13, 2020 · 13 comments

Comments

@SalehShmali
Copy link

1- AssertionError: Could not compute output Tensor("rpn_reg_loss/truediv:0", shape=(), dtype=float32) in faster rcnn
2-Incompatible shapes: [8,9216] vs. [8]
[[node gradient_tape/reg_loss/mul/BroadcastGradientArgs (defined at e:/faster_rcnn/rpn_trainer.py:60) ]] [Op:__inference_train_function_12539] in rpn alone

@oygenvalue
Copy link

Are you doing this without modifying anything or are you trying to implement your own code?

@SalehShmali
Copy link
Author

without modifying anything

@FurkanOM
Copy link
Owner

Probably tf version mismatch, try tf 2.0 not others.

@SalehShmali
Copy link
Author

my tf version is 2.3.1 is that mismatch and i am working with cpu not gpu??

@oygenvalue
Copy link

oygenvalue commented Dec 14, 2020 via email

@oygenvalue
Copy link

oygenvalue commented Dec 14, 2020 via email

@SalehShmali
Copy link
Author

i tried on tf2.0 it was aproblems on tensorflow datasets like this :
google.protobuf.json_format.ParseError: Message type "tensorflow_datasets.DatasetInfo" has no field named "downloadSize".
Available Fields(except extensions): ['name', 'description', 'version', 'citation', 'sizeInBytes', 'location', 'downloadChecksums', 'schema', 'splits', 'supervisedKeys', 'redistributionInfo']

@SalehShmali
Copy link
Author

what version of tfds is suitable?

@colindecourt
Copy link

Hi,
Using a batch size of 1 I resolved with this issue. I'm looking to make it work with batch size > 1. I'll let you know if I figured out how to make it work for batch size > 1. I'm using tf 2.4.

@wr0112358
Copy link

The batch_size problem with tf 2.4 is the result of a change in the huber loss function:
https://github.com/tensorflow/tensorflow/blob/v2.4.0/tensorflow/python/keras/losses.py#L1426
https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/keras/losses.py#L885

tf2.0:

tf.losses.Huber(reduction=tf.losses.Reduction.NONE)(tf.ones(shape=(2,16500,4)),tf.ones(shape=(2,16500,4))).shape
TensorShape([2, 16500, 4])

tf 2.4:

tf.losses.Huber(reduction=tf.losses.Reduction.NONE)(tf.ones(shape=(2,16500,4)),tf.ones(shape=(2,16500,4))).shape
TensorShape([2, 16500])

Fixing the bug for tf 2.4 is easy: Remove the additional reduce_sum in the reg_loss in line 218.
https://github.com/FurkanOM/tf-faster-rcnn/blob/master/utils/train_utils.py#L218

@ruman1609
Copy link

ruman1609 commented Feb 28, 2022

Anyone know with Tensorflow 2.8.0, seems the error now change to

ValueError: in user code:    File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1021, in train_function  *        return step_function(self, iterator)    File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1010, in step_function  **        outputs = model.distribute_strategy.run(run_step, args=(data,))    File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 1000, in run_step  **        outputs = model.train_step(data)    File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 861, in train_step        self._validate_target_and_loss(y, loss)    File "/usr/local/lib/python3.7/dist-packages/keras/engine/training.py", line 819, in _validate_target_and_loss        'Target data is missing. Your model was compiled with '    ValueError: Target data is missing. Your model was compiled with loss=ListWrapper([None, None, None, None, None, None, None, None, None]), and therefore expects target data to be provided in 'fit()'

@colindecourt
Copy link

Hi @ruman1609,
Try the solution I proposed in #17 by changing the format of inputs and targets. It seems you don't give target data to the fit function. Otherwise, downgrade your tf version.

@ruman1609
Copy link

ruman1609 commented Feb 28, 2022

Hi @colindecourt I already do like you do, and like @wr0112358 did. Still the error occurred so right now I using 2.1.0 version. The error log was just like I sent before is using TF 2.8.0. That's why I downgrade my TF to 2.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants