nlp-with-transformers / notebooks

Jupyter notebooks for the Natural Language Processing with Transformers book

Home Page:https://transformersbook.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chapter 2: model output doesn't have last_hidden_state field

Claus1 opened this issue · comments

  • [x ] Text Classification

config:
python 3.10
GPU nvidia 3900
OS Manjaro
Using transformers v4.25.1
Using datasets v2.7.0

02_classification.ipynb in block with outputs.last_hidden_state.size() raises exception:
AttributeError: 'SequenceClassifierOutput' object has no attribute 'last_hidden_state'

Output state is
SequenceClassifierOutput(loss=None, logits=tensor([[ 0.0083, 0.1523, 0.1225,
-0.0196, 0.1857, -0.0053]],
device='cuda:0'), hidden_states=None, attentions=None)

To Reproduce

Steps to reproduce the behavior:

  1. run notebook.
  2. get exception.