Thanks Richard!
The link is very helpful. I will take a close look.
BTW, if I assign a tensor value instead of None to the hidden, like this:
hidden = torch.zeros(1, hidden_size)
I am getting:
python value of type ‘int’ cannot be used as a value:
@torch.jit.script
def rnn_loop(x):
hidden = torch.zeros(1, hidden_size)
~~~~~~~~~~~ <— HERE
for x_t in x.split(1):
x, hidden = model(x_t, hidden)
return x
File “/home/liqun/pytorch/torch/jit/init.py”, line 751, in script
_jit_script_compile(mod, ast, _rcb, get_default_args(obj))
Actually this was the error I have been getting. The None assignment was just to workaround this error to see how far I can go.
And if I assign a tensor value to the hidden outside of the loop, I am getting:
python value of type ‘Tensor’ cannot be used as a value:
@torch.jit.script
def rnn_loop(x):
#hidden = torch.zeros(1, hidden_size)
for x_t in x.split(1):
x, hidden = model(x_t, hidden)
~~~~~~ <— HERE
Thanks again,
Liqun