-
Notifications
You must be signed in to change notification settings - Fork 73
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
[MobileFormer]Dimensions must be equal [Add Layer] #103
Comments
First, your model has The first problem is that the output of
This For now, let's transpose the output of
The first Reshape shape error was avoided. But now another Reshape with a similar shape causes an error. Append to JSON.
The error occurs again. Your model has a rather tricky structure for automatically converting models. Therefore, you will need to repeat the aforementioned operations several times and perform trial and error until there are no more errors. It is not a difficult task, just tedious.
Note that your model seems to contain If you want to decompose
The following is a sample command if you need output in Keras h5 format.
But unfortunately your model does not seem to support output to h5 format.
As a workaround, you can use the
Finally, if you don't mind me asking, could you tell me the official name of this model? If it is a publicly available model, I would like to use it in my research to enhance this tool. Including the name of the model in the title of the isuue would be very useful for engineers around the world to explore the information. |
Hi Master PINTO0309, Thank you so much for the timely response. Your explanation is very clear. Showing me one example is enough, but you completed all the tedious work and provided extra information on the downstream issues. I cannot thank you enough! I can replicate your result locally so feel free to close this issue. The model is a fine-tuned MobileFormer by Chen Et al., repo:https://github.com/AAboys/MobileFormer and paper: https://arxiv.org/abs/2108.05895. I was trying to replicate their results and see their performances on some fine-grained datasets. Most of my workflow is on tensorflow so since yesterday I became fixated to find a way to convert pytorch to tf and have a keras model to do some extra tinkering. It wasn't even close until I find your repo! I guess this transpose/reshape issue might be linked to transformer achitecture which later might quite prevalent in production. This particular model is not very representative in terms of vision transformers because it is only for my research area. SwinTransformer is more well-known and it has well maintained repo in both pytorch https://github.com/microsoft/Swin-Transformer as well as tensorflow https://github.com/rishigami/Swin-Transformer-TF. The downside is that Swin is a much larger model than this. Actually, there is another issue with this coverted model. The output values are a little off compared to the original pytorch model or the tensorflow representation from onnx_tf. I don't know if this is on your priority list but if you are interested in this, I can provide more info or create a new issue. Converting to TF is not a must for me so for now I am happy that all the codes runs through. Feel free to close this issue. Thank you so much! |
Thank you!
I am very interested. I believe that to be useful to other researchers, I need to work out all the little bugs that you have pointed out. I am very sorry to make this a hassle, but I need your help to improve this tool. I would appreciate it if you could post another issue if you can. I will close this issue once, but will continue to improve the tool. Thanks again. 👍 |
Cool. I will do that later this week. |
Issue Type
Others
onnx2tf version number
1.4.2
onnx version number
1.12.0
tensorflow version number
2.10.1
Download URL for ONNX
https://drive.google.com/file/d/1vGzO9MZGX-yGz6ATm4yHVJMASZACuy2t/view?usp=share_link
Parameter Replacement JSON
Description
Hi, thank you so much for actively maintaining this useful repo. I am trying to convert my custom pytorch model to onnx and then to keras for further tuning. I exported the model using
opset==12
. The issue occurred during convertion with an ADD LAYER when I runconvert('onnx/py_model.onnx')
.In attempting to solve this problem, I provided the parameter replacement file to the converter but got the same issue. It looks like one input for the layer is in NHWC and the other is in NCHW for op_name Add_282 (number 1 on the screenshot) in this case. From the error, I can see that one of the input for add is in correct order(NCHW) but the other one is in NHWC. So I look back to the operation Add_263 (number 2 on the screenshot) that is responsible for generating the wrong input and I found that the keras input for this operation is already in NHWC. I did not trace further up because I think that illustrate my problem: it seems like one of the input for the Add_282 is in correct shape.
So I wonder if there is some quick fix for this, like if I forgot to set some parameter or did incorrectly for parameter replacement, or version issue? I also find #17 but at the very end you said no need to do parameter replacement for transpose operation after 1.1.38 and after opset>11. I apologize in advance if I missed something super obvious, but could you provide some tips on how to fix this? Thanks again!
Screenshot
The text was updated successfully, but these errors were encountered: