CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

What are the names of nodes created using the Sequential function when using the C++ evaluation interface?

Open e-thereal opened this issue 10 years ago • 5 comments

I've trained the CNN from the MNIST example (https://github.com/Microsoft/CNTK/blob/master/Examples/Image/GettingStarted/README.md, 02_OneConv.cntk) and I would like to be able to visualize the learned weights. Therefore, I'm using the C++ evaluation interface. I can identify and evaluate the node names of the hidden layers (e.g., ol.x.x.x._.x.x is the name of the first convolutional layer after applying the bias and the ReLU). However, I'm having trouble to identify the name of the weights. From the trace:

Validating network. 27 nodes to process in pass 1.

Validating --> labels = InputValue() :  -> [10 x *]
Validating --> model.arrayOfFunctions[8].W = LearnableParameter() :  -> [10 x 128]
Validating --> model.arrayOfFunctions[7].arrayOfFunctions[0].W = LearnableParameter() :  -> [128 x 7 x 7 x 32]
Validating --> model.arrayOfFunctions[4].W = LearnableParameter() :  -> [5 x 5 x 16 x 32]
Validating --> model.arrayOfFunctions[1].W = LearnableParameter() :  -> [5 x 5 x 1 x 16]
Validating --> ol.x.x.x._.x.x._.x.ElementTimesArgs[0] = LearnableParameter() :  -> [1 x 1]
Validating --> features = InputValue() :  -> [28 x 28 x 1 x *]
Validating --> ol.x.x.x._.x.x._.x = ElementTimes (ol.x.x.x._.x.x._.x.ElementTimesArgs[0], features) : [1 x 1], [28 x 28 x 1 x *] -> [28 x 28 x 1 x *]
Validating --> ol.x.x.x._.x.x._.c = Convolution (model.arrayOfFunctions[1].W, ol.x.x.x._.x.x._.x) : [5 x 5 x 1 x 16], [28 x 28 x 1 x *] -> [28 x 28 x 16 x *]
Validating --> model.arrayOfFunctions[1].b = LearnableParameter() :  -> [1 x 1 x 16]
Validating --> ol.x.x.x._.x.x._.res.x = Plus (ol.x.x.x._.x.x._.c, model.arrayOfFunctions[1].b) : [28 x 28 x 16 x *], [1 x 1 x 16] -> [28 x 28 x 16 x *]
Validating --> ol.x.x.x._.x.x = RectifiedLinear (ol.x.x.x._.x.x._.res.x) : [28 x 28 x 16 x *] -> [28 x 28 x 16 x *]

It looks to me that the name of the weights should be model.arrayOfFunctions[1].W, but I'm getting the error message that there is no node with the given name. Are there any special rules as to how elements of an array translate to node names? I've found that in the context of BS model editing, dots and brackets are replaced with underscores, but at least dots are usually kept when using the C++ evaluation interface, but I don't know how brackets are handeled.

e-thereal avatar Oct 25 '16 13:10 e-thereal

It should be the same. Have you tried model_arrayofFunctions[1]_W?

cha-zhang avatar Oct 26 '16 03:10 cha-zhang

Thanks for your reply. Unfortunately, the problem is the same as before. This is the full message with exception type:

terminate called after throwing an instance of 'Microsoft::MSR::CNTK::ExceptionWithCallStack<std::runtime_error>'
  what():  Output model_arrayOfFunctions[1]_W not found in CNTK model.

e-thereal avatar Oct 26 '16 07:10 e-thereal

Please try to replace all square bracket with "_" as well.

cha-zhang avatar Nov 01 '16 16:11 cha-zhang

Closing, feel free to reopen.

n17s avatar Nov 03 '16 04:11 n17s

@cha-zhang Thanks for your reply. Unfortunately, this also did not help. I've tried

model.arrayOfFunctions[1].W
model.arrayOfFunctions[1]_W
model.arrayOfFunctions_1_.W
model.arrayOfFunctions_1__W
model.arrayOfFunctions_1_W

but none of them worked.

e-thereal avatar Nov 03 '16 07:11 e-thereal