Chaining LSTMs stopped working on RC3
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 "
[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
i got the same error.
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
Many thanks, now it works well again. @mfuntowicz
Morgan, Thank you very much!