I got "in matMul: inputs must be rank 2" error when I used retained model.
See original GitHub issueHi I love Emoji Scavenger Hunt. I want to play the game with my own trained model. But I got the following error. Can you please help me?
Summary
I created a model and deployed it. However I got Error: Error in matMul: inputs must be rank 2, got ranks 1 and 2.
error during starting the game. I want to solve it.
Steps to Reproduce
# Git clone from my forked repo
$ git clone --depth 1 --branch matmul-error https://github.com/y-zono/emoji-scavenger-hunt.git
# Training
$ cd emoji-scavenger-hunt/training/
$ docker build -t model-builder .
$ docker run -v /xxx/xxx/emoji-scavenger-hunt/training/data:/data -it model-builder
# Copy the trained files into dist
$ cp data/saved_model_web/group1-shard1of1 ../dist/model/group1-shard1of1
$ cp data/saved_model_web/tensorflowjs_model.pb ../dist/model/web_model.pb
$ cp data/saved_model_web/weights_manifest.json ../dist/model/weights_manifest.json
# Run the app
$ cd ..; yarn prep; yarn dev
# Open browser and click "LET'S PLAY"
http://localhost:3000
Expected Results
The game is started normally.
Actual Results
The following message was showed on the page.
It looks like your browser or device doesn’t support this experiment. It’s designed to work best on mobile (iOS/Safari or Android/Chrome). 😭
The following error was occurred at matmul.ts
Error: Error in matMul: inputs must be rank 2, got ranks 1 and 2.
https://github.com/tensorflow/tfjs-core/blob/master/src/ops/matmul.ts#L49
Notes
- The versions are the following.
@tensorflow/tfjs-converter@0.1.0
@tensorflow/tfjs-core@0.6.0
tensorflow v1.7.0 for training
-
Chrome browser version is 65.0.3325.181(Official Build)(64bit)
-
The original trained model worked normally on my local PC.
-
I added some images into my own forked repo for training and changed some files like game.ts and scavenger_classes.ts.
https://github.com/google/emoji-scavenger-hunt/compare/master...y-zono:matmul-error
- I downloaded the cat and dog images from image-net
$ wget http://www.image-net.org/api/text/imagenet.synset.geturls?wnid=n02123045 -O cat.txt
$ wget http://www.image-net.org/api/text/imagenet.synset.geturls?wnid=n02087122 -O dog.txt
$ i=0; for file in `head -100 cat.txt`;do wget $file -O cat-$i.jpg; let i++ ;done
$ i=0; for file in `head -100 dog.txt`;do wget $file -O dog-$i.jpg; let i++ ;done
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top GitHub Comments
@tushuhei The issue was solved. Thank you!
@jbruwer Looks like the upstream issue is not fixed fully. I still see that the required op
reshape
is removed after conversion. I will follow up tensorflow/tfjs#85 on this. We can keep the branch flag for tensorflow repo as is because it is to fix the path to retrain.py and separated from this issue.