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

'Encoder' object has no attribute 'tx_proj' #57

Open
jivatneet opened this issue Jan 24, 2021 · 3 comments
Open

'Encoder' object has no attribute 'tx_proj' #57

jivatneet opened this issue Jan 24, 2021 · 3 comments

Comments

@jivatneet
Copy link

I was successfully able to run the LSTM based pointer generator. While running the transformer_encoder branch with LSTM=false, I encounter this error:

File "training_ptr_gen/train.py", line 400, in <module>
    train_processor.trainIters(config.max_iterations, args.model_file_path)
  File "training_ptr_gen/train.py", line 341, in trainIters
    loss = self.train_one_batch(batch)
  File "training_ptr_gen/train.py", line 273, in train_one_batch
    encoder_outputs, encoder_feature, encoder_hidden = self.model.encoder(enc_batch, enc_lens, enc_padding_mask)
  File "/srv/home/kaur/pointer_summarizer/lstmpg/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/srv/home/kaur/pointer_summarizer/training_ptr_gen/model.py", line 108, in forward
    word_embed_proj = self.tx_proj(embedded)
  File "/srv/home/kaur/pointer_summarizer/lstmpg/lib/python3.6/site-packages/torch/nn/modules/module.py", line 779, in __getattr__
    type(self).__name__, name))
torch.nn.modules.module.ModuleAttributeError: 'Encoder' object has no attribute 'tx_proj'

Any help regarding this would be appreciated, thanks.

@v-chuqin
Copy link

You can set use_lstm=True to handle this issue.

@jivatneet
Copy link
Author

Thanks for the reply @v-chuqin, but I wanted to use the transformer-based encoder and hence set use_lstm=False. With use_lstm=True, it is working fine.

@Tinarights
Copy link

How did you solve that? I want to use transformers and I got the same error

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

3 participants