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

Error in conversion from Tensorflow Model to CNTK Model #11

Closed
coolrishi2005 opened this Issue Nov 30, 2017 · 10 comments

Comments

Projects
None yet
4 participants
@coolrishi2005
Copy link

coolrishi2005 commented Nov 30, 2017

I have used the code at the link (https://github.com/aymericdamien/TensorFlow-Examples/blob/master/examples/4_Utils/save_restore_model.py) to create and store a model in tensorflow.

I am converting the saved tensorflow model to cntk using the steps mentioned in MMdnn. At the final step of convresion, i.e. while generating CNTK Model from CNTK Code Snippet, I am getting some error.

Following is the traceback:

(C:\Program Files\Anaconda3\envs\py35) MMdnn-master\mmdnn\conversion\cntk>python -m mmdnn.conversion.examples.cntk.imagenet_test -n cntkModel_3_5.py -w IRModel_3_5.npy --dump cntkModel_3_5.dnn
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\envs\py35\lib\runpy.py", line 184, in _run_mo
dule_as_main
"main", mod_spec)
File "C:\Program Files\Anaconda3\envs\py35\lib\runpy.py", line 85, in _run_cod
e
exec(code, run_globals)
File "C:\Program Files\Anaconda3\envs\py35\lib\site-packages\mmdnn\conversion
examples\cntk\imagenet_test.py", line 57, in
tester = TestCNTK()
File "C:\Program Files\Anaconda3\envs\py35\lib\site-packages\mmdnn\conversion
examples\cntk\imagenet_test.py", line 17, in init
super(TestCNTK, self).init()
File "C:\Program Files\Anaconda3\envs\py35\lib\site-packages\mmdnn\conversion
examples\imagenet_test.py", line 104, in init
self.MainModel = import(self.args.n)
File "D:\Rishi\Machine Learning\CNTK\MMdnn-master\mmdnn\conversion\cntk\cntkMo
del_3_5.py", line 31
Reshape_1 = cntk.reshape(Placeholder_1, shape = (,) name = 'Reshape_1'
)
^
SyntaxError: invalid syntax

@kitstar

This comment has been minimized.

Copy link
Contributor

kitstar commented Nov 30, 2017

Hi @coolrishi2005,
Thanks for helping test the converter. Tensorflow converter is in very initial state, any question and issue is welcome.

Fix some bugs and seems it works. Tensorflow -> IR command (step 1) is

python -m mmdnn.conversion._script.convertToIR -node add -f tensorflow -d IRModel_3_5 -n /tmp/model.ckpt.meta -w /tmp/model.ckpt

Note: Please specify the output node of tensorflow model, which can help the converter trims useless nodes. like -node add in above command.

For this model, we can get the output node from codes:

code

or from tensorboard

tensorboard

Thanks.

@kitstar kitstar self-assigned this Nov 30, 2017

@kitstar kitstar added the bug label Nov 30, 2017

@coolrishi2005

This comment has been minimized.

Copy link
Author

coolrishi2005 commented Nov 30, 2017

Thanks kitstar for the response.
The model has been converted successfully now from tf -> cntk.
The issue was due to those useless nodes only, which got trimmed while generating IR Code from tf.

@kitstar kitstar closed this Nov 30, 2017

@mhajiaghayi

This comment has been minimized.

Copy link

mhajiaghayi commented Aug 21, 2018

hi there, i'm trying to convert a transformer model that is trained with tf to cntk model. I get the following error.

image

@mhajiaghayi

This comment has been minimized.

Copy link

mhajiaghayi commented Aug 21, 2018

it seems it's not recognizing the attention layer. is there any way to get around that?

@namizzz

This comment has been minimized.

Copy link
Member

namizzz commented Aug 22, 2018

Hi @mhajiaghayi , could you please provide your model files?

@mhajiaghayi

This comment has been minimized.

Copy link

mhajiaghayi commented Aug 22, 2018

hi namizz, how would you like me to send it to you? it's 800meg.

@namizzz

This comment has been minimized.

Copy link
Member

namizzz commented Aug 22, 2018

Hi @mhajiaghayi , any free cloud storage is ok.

@mhajiaghayi

This comment has been minimized.

Copy link

mhajiaghayi commented Aug 22, 2018

hi @namizzz , you can find the model here https://1drv.ms/f/s!AqysHcfYW1hSgc57psU_Bh8MDND74A and I used the following script to convert it

mmconvert -sf tensorflow -in checkpoints\model-0.meta -iw checkpoints\model-0 --dstNodeName output/fwside1/fwside1/fully_connected/Relu -df cntk -om cntk-model

@namizzz

This comment has been minimized.

Copy link
Member

namizzz commented Aug 23, 2018

Hi @mhajiaghayi , MMdnn doesn't support RNN network now. Sorry,thanks!

@mhajiaghayi

This comment has been minimized.

Copy link

mhajiaghayi commented Aug 24, 2018

hi @namizzz, would you please look at this model located in https://1drv.ms/f/s!AqysHcfYW1hSgc8KG_BnQRrwT7vCJA? . This model doesn't use any RNN or attention layer.
mmconvert -sf tensorflow -in checkpoints\model-0.meta -iw checkpoints\model-0 --dstNodeName output/fwside1/fwside1/fully_connected/Relu -df cntk -om cntk-model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.