-
Notifications
You must be signed in to change notification settings - Fork 74k
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
RuntimeError: Given shapes, [1,784] and [784,100], are not broadcastable.Node number 1 (MUL) failed to prepare. #60345
Comments
Hi @aanujdu Thanks for reporting the issue. @sachinprasadhs I was able to reproduce this issue. Please find the gist here. Thanks. |
The issue seems to be with the representative dataset which you are using. Below is the corrected way to use the
With the above changes, I'm able to convert the model without any issues. Attaching the Gist for reference here https://gist.github.com/sachinprasadhs/fb4b62e7e37b5308217addbe9c2edd5f. |
Thanks for the response @sachinprasadhs . I can reproduce a working conversion with your code. However, I am still not sure what is the actual issue. Are you saying I need to specify the output as a dictionary with keys as the names of the variables I specify in the input signature? If that is the case, could you please let me know how I write the code if I want to use the train_images_flat array, and the random array as my representative dataset? The example you have given is for random inputs, which works for sure, but I want to know how to extend it for an actual usecase with real variables. I tried the following code using the dictionary format, but it still gives me a similar error.
Error:
Maybe, what might help is, if you can clearly explain the set of rules I need to follow when I am using the representative_data_gen function, instead of a working example. Thanks, |
Well in that case, according to the data which you have, you should provide in the below format.
Here is the working Gist. |
This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. |
This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. |
1. System information
I am using Google Colab. Gives the output Linux a0c9eeb98a07 5.10.147+ #1 SMP Sat Dec 10 16:00:40 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux, when I run uname -a.
Tensorflow Version: 2.12.0
2. Code
Reference TensorFlow Model Colab: The basic conversion to TFLite without any representative dataset works just fine. However, the problematic portions are cells 4, and 5, where I am trying to perform a TFLite conversion with a representative dataset.
3. Failure after conversion
It throws the following error.
Following is the netron image and the problematic node info.
I do not suspect the issue to be with the broadcasting of scalar r in the multiplication with W1_1, because the code here works just fine. The only difference in this new code is that the call implementation only takes r as the input argument and returns the product of r and W1_1, which does not emit the error shown above, even though there is a broadcast.
The text was updated successfully, but these errors were encountered: