CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

How can I load two models at a time?

Open qingwang24 opened this issue 10 years ago • 9 comments

Hi, The command "m=LoadModel (modelFileName, format="cntk")" can load a model from a disk file. But now I want to load two models at a time. How can I do this? Does CNTK support this load action? Looking forward to your reply! Thank you.

qingwang24 avatar Jun 25 '16 09:06 qingwang24

Hi, Could you elaborate more on the reason behind loading multiple models? i.e. Are you trying to train multiple models concurrently?, evaluate them?, daisy chain them?

For now, you can load multiple models for evaluation using the evaluation engine (EvalDLL) in Windows (soon for Linux). You can refer to the Evaluate Multiple Models page for further information.

gaizkan avatar Jun 27 '16 08:06 gaizkan

Thanks for your reply. Well, I want to do joint training. So I need to use these two well trained models as initialization. The output of the first model is feed to the input of the second model. But I find the last loaded model is regarded as default model and the firstly loaded model does not exit any more.

qingwang24 avatar Jun 27 '16 15:06 qingwang24

you can still use a.xyz to reference the other model if a is the variable if loaded model. please consult the cntk pdf book for additional info.

-------- Original message --------
From: xqustc
Date: 6/27/16 08:54 (GMT-08:00)
To: Microsoft/CNTK
Subject: Re: [Microsoft/CNTK] How can I load two models at a time? (#627)

Thanks for your reply. Well, I want to do joint training. So I need to use these two well trained models as initialization. The output of the first model is feed to the input of the second model. But I find the last loaded model is regarded as default model and the firstly loaded model does not exit any more.


You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/Microsoft/CNTK/issues/627#issuecomment-228788775

dongyu888 avatar Jun 27 '16 16:06 dongyu888

Hi, I have consulted the cntk book, but still can not solve it. Here is the command in my mel file: m1 = LoadModel("$CurrModel1$", format="cntk") SetDefaultModel(m1) m2 = LoadModel("$CurrModel2$", format="cntk") newnode1 = BFF(IBM.S, 2048, 129) newnode2 = Plus(DNN_B_L1.BFF2.FF.P, DNN_B_L1.BFF1.FF.P) setInputs(DNN_B_L1.BFF_final,newnode2,newnode1)

IBM.S refer to node in "$CurrModel1". DNN_B_L1.BFF2.FF.P, DNN_B_L1.BFF1.FF.P, and DNN_B_L1.BFF_final all refer to nodes in "$CurrModel2".

I got error as follows: EXCEPTION occurred: FindSymbols could not find a symbol for DNN_B_L1.BFF_final

If I set "$CurrModel2" as default model. Then I got error too: EXCEPTION occurred: Parameter name could not be resolved 'IBM.S'

qingwang24 avatar Jun 29 '16 07:06 qingwang24

Use m2.DNN_B_L1.BFF_final

dongyu888 avatar Jun 29 '16 18:06 dongyu888

Hi, thank you. Like what you said, I use m2.DNN_B_L1.BFF_final to refer to node in the secode model. But 'm2.DNN_B_L1.BFF1.FF.P' could not be resolved either. And I could not get the parameters in the second model by using m2.DNN_B_L1.BFF1.W and m2.DNN_B_L1.BFF1.B.

qingwang24 avatar Jul 05 '16 03:07 qingwang24

Something might have been changed? The following is examples from the old test cases (in modelEditor.txt in the repository):

Copy(m2.L2..W, L2..W, copy=value)

Copy(m2.L2..B, L2..B, copy=value)

dongyu888 avatar Jul 05 '16 22:07 dongyu888

Hi, thank you very much. Like what you said, I can get the parameters by using 'Copy' function first not just by using m2.L2..W or m2.L2..B.

qingwang24 avatar Jul 11 '16 00:07 qingwang24

This issue has been dormant for a long while, please check out the latest CNTK release. Model evaluation in CNTK has been improved significantly. Please check https://docs.microsoft.com/en-us/cognitive-toolkit/CNTK-Evaluation-Overview If you still run into problems, please open a new issue.

wolfma61 avatar Jul 03 '17 14:07 wolfma61