CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

When to use C.layers.Signature?

Open whuala opened this issue 8 years ago • 2 comments

I was tying to follow the tutorial 204 to build a seq2seq. In this tutorial, there's a @C.layers.Signature for both create_model_greedy and create_criterion_function while create_model_train isn't. Why is it?When I try to add one to create_model_train like

@C.layers.Signature(input=InputSequence[C.layers.Tensor[input_vocab_dim]],
                        labels=LabelSequence[C.layers.Tensor[label_vocab_dim]])

it error out with

TypeError: argument labels's type SequenceOver[labelAxis][Tensor[69]] is incompatible with the type SequenceOver[labelAxis_times_1_minus_1][Tensor[69]] of thepassed Variable

What does labelAxis_times_1_minus_1 actually mean here acctually? Thanks for your help!

whuala avatar Mar 06 '18 15:03 whuala

labelAxis_times_1_minus_1 comes from sequence.slice that removes BOS from the label. sequence.slice produces an output sequence with different length than input sequence, thus a new sequence axis is created with postfix of _times_1_minus_1 to note it's relationship with labelAxis. You need to use the signature with matching sequence axis.

ke1337 avatar Mar 06 '18 19:03 ke1337

Thanks! Closing...

whuala avatar Mar 07 '18 12:03 whuala