CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

Chaining LSTMs stopped working on RC3

Open slaweks17 opened this issue 9 years ago • 4 comments

Hi, I have a function that I have used to create a ResNet-style chain of LSTMs: def createLSTMnet2(input_var , num_hidden_layers1, hidden_layer_dim1, output_dim): r=l.Recurrence(l.LSTM(hidden_layer_dim1, use_peepholes=LSTM_USE_PEEPHOLES, enable_self_stabilization=LSTM_USE_STABILIZATION))(input_var) for i in range(1, num_hidden_layers1): r1=l.Recurrence(l.LSTM(hidden_layer_dim1, use_peepholes=LSTM_USE_PEEPHOLES, enable_self_stabilization=LSTM_USE_STABILIZATION))(r) r=r+r1
return linear_layer(r, output_dim)

This function stopped working on RC3. When executing the first line r=l.Recurrence(l.LSTM(hidden_layer_dim1, use_peepholes=LSTM_USE_PEEPHOLES, enable_self_stabilization=LSTM_USE_STABILIZATION))(input_var)

I get: Traceback (most recent call last): File "C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py35\lib\site-packages\IPython\core\interactiveshell.py", line 2847, in run_code exec(code_obj, self.user_global_ns, self.user_ns) File "", line 3, in enable_self_stabilization=LSTM_USE_STABILIZATION))(input_var) File "C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py35\lib\site-packages\cntk\ops\functions.py", line 384, in call return self.clone(CloneMethod.share, arg_map) File "C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py35\lib\site-packages\cntk\internal\swig_helper.py", line 69, in wrapper result = f(*args, **kwds) File "C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py35\lib\site-packages\cntk\ops\functions.py", line 557, in clone return super(Function, self).clone(method, substitutions) File "C:\local\Anaconda3-4.1.1-Windows-x86_64\envs\cntk-py35\lib\site-packages\cntk\cntk_py.py", line 1598, in clone return _cntk_py.Function_clone(self, *args) RuntimeError: PastValue/FutureValue Function 'PastValue: Output('Block5263_Output_0', [#], [50]) -> Output('PastValue5178_Output_0', [???], [???])': Input operand 'Output('Block5263_Output_0', [#], [50])' with #dynamic axes != 2 (1 sequence axis and 1 batch axis) is not supported.

[CALL STACK] > CNTK::NDMask:: MaskedCount - CNTK:: Unpooling (x4) - CNTK::Function:: ReplacePlaceholders - CNTK::Function:: Clone - PyInit__cntk_py (x2) - PyCFunction_Call - PyEval_GetFuncDesc - PyEval_EvalFrameEx (x2) - PyEval_GetFuncDesc (x2) - PyEval_EvalFrameEx

Any help would be appreciated.

Regards, Slawek

slaweks17 avatar May 30 '17 03:05 slaweks17

i got the same error.

main76 avatar May 31 '17 07:05 main76

Hi @slaweks17, @Master76

My supposition is that you're using an input variable without sequence axis. This is why the CNTK engine tells you about the number of dynamic axis being different from 2 (only 1 in your case, the batch axis).

This is a change introduced in CNTK, where sequence inputs need to be define through the sequence.input() function rather than just input():

# Initial way
from cntk import sequence
x = sequence.input((whatever, shape, needed))

# Or using functional way, using layers typing library
from cntk.layers.typing import Sequence, Tensor
x = input(**Sequence[Tensor[(whatever, shape, needed)]])

Hope it helps, Morgan

mfuntowicz avatar Jun 01 '17 23:06 mfuntowicz

Many thanks, now it works well again. @mfuntowicz

main76 avatar Jun 02 '17 03:06 main76

Morgan, Thank you very much!

slaweks17 avatar Jun 02 '17 04:06 slaweks17