Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'custom_lstms.py': name 'List' is not defined #44

Closed
FedericOldani opened this issue Jan 25, 2019 · 9 comments
Closed

'custom_lstms.py': name 'List' is not defined #44

FedericOldani opened this issue Jan 25, 2019 · 9 comments

Comments

@FedericOldani
Copy link

I got this error, but i'm not able to find where the error come from.

  File "lstm_test.py", line 300, in <module>
    test_script_stacked_bidir_rnn(5, 2, 3, 7, 4)

  File "lstm_test.py", line 275, in test_script_stacked_bidir_rnn
    rnn = script_lstm(input_size, hidden_size, num_layers, bidirectional=True)

  File "lstm_test.py", line 50, in script_lstm
    hidden_size])

  File "C:\Users\feder\Anaconda3\lib\site-packages\torch\jit\__init__.py", line 950, in init_then_register
    original_init(self, *args, **kwargs)

  File "lstm_test.py", line 189, in __init__
    other_layer_args)

  File "lstm_test.py", line 150, in init_stacked_lstm
    layers = [layer(*first_layer_args)] + [layer(*other_layer_args)

  File "C:\Users\feder\Anaconda3\lib\site-packages\torch\jit\__init__.py", line 950, in init_then_register
    original_init(self, *args, **kwargs)

  File "lstm_test.py", line 129, in __init__
    ReverseLSTMLayer(cell, *cell_args),

  File "C:\Users\feder\Anaconda3\lib\site-packages\torch\jit\__init__.py", line 951, in init_then_register
    _create_methods_from_stubs(self, methods)

  File "C:\Users\feder\Anaconda3\lib\site-packages\torch\jit\__init__.py", line 912, in _create_methods_from_stubs
    self._create_methods(defs, rcbs, defaults)

  File "C:\Users\feder\Anaconda3\lib\site-packages\torch\jit\annotations.py", line 52, in get_signature
    return parse_type_line(type_line)

  File "C:\Users\feder\Anaconda3\lib\site-packages\torch\jit\annotations.py", line 90, in parse_type_line
    arg_ann = eval(arg_ann_str, _eval_env)

  File "<string>", line 1, in <module>

NameError: name 'List' is not defined
@FedericOldani
Copy link
Author

I confirm the bug

@FedericOldani FedericOldani changed the title name 'List' is not defined 'custom_lstms.py': name 'List' is not defined Jan 25, 2019
@apaszke
Copy link
Contributor

apaszke commented Jan 25, 2019

Please follow the issue template and at least post a minimal example that would let us reproduce this error.

@FedericOldani
Copy link
Author

The error is raised when I run rnns\fastrnns\custom_lstm.py (I renamed it 'lstm_test.py')
The problem is in the test of bidirectional lstm, the Traceback error is posted above.
Thank you for your help

@surgan12
Copy link

surgan12 commented Feb 27, 2019

@FedericOldani

https://github.com/pytorch/pytorch/blob/44a607b90c9bba0cf268f833bae4715221346709/torch/jit/annotations.py#L33

Check this in the annotations.py of your pytorch version.
Probably this is missing .

@kangkang59812
Copy link

So how to fix this ? update to pytorch1.1 ?
I use pytorch1.0.1 and in annotations.py it has

_eval_env = {
    'torch': Module('torch', {'Tensor': torch.Tensor}),
    'Tensor': torch.Tensor,
    'typing': Module('typing', {'Tuple': Tuple}),
    'Tuple': Tuple,
}

@FedericOldani
Copy link
Author

For fast fixing, I remove all the lines @jit.script_method. Let me know if you solve the problem.

@kangkang59812
Copy link

@FedericOldani But it seems that the custom lstm has no relation with jit . It also woks if class LSTMCell(nn.Module) without undering jit. And LSTMCell(nn.Module) runs faster than LSTMCell(jit.Module).

@spzala
Copy link
Contributor

spzala commented May 29, 2023

I was looking at the issue from triage aspect, and I couldn't reproduce the error, and I see don't rnns\fastrnns\custom_lstm.py anymore. Perhaps, the issue is not relevant and now and we should close. Thanks! cc @xuzhao9

@xuzhao9
Copy link
Contributor

xuzhao9 commented Jul 26, 2023

Yes, we should close this issue because it is not relevant anymore.

@xuzhao9 xuzhao9 closed this as completed Jul 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants