How to Solve PyTorch Lightning error KeyError: ‘hidden_ states’
Problem description: PyTorch Lightning error: KeyError: ‘hidden_ states’.
model = BertModel.from_pretrained('bert-base-uncased')
Solution: add a parameter after the above code, config=BertConfig.from_pretrained(‘bert-base-uncased’,output_hidden_states=True), as below:
model = BertModel.from_pretrained('bert-base-uncased', config=BertConfig.from_pretrained('bert-base-uncased',output_hidden_states=True))
Read More:
- [pl.LightningModule] spaCy & pytorch-lightning Error
- [Solved] pytorch Error: KeyError: tensor(2, device=‘cuda:0‘)
- [Solved] raise KeyError(key) from err KeyError: ‘Dates‘
- [Solved] Pytorch-transformers Error: AttributeError: ‘str‘ object has no attribute ‘shape‘
- [Solved] Pylint Warning: An attribute defined in json.encoder line 158 hides this methodpylint(method-hidden)
- numpy.concatenate() 253rd; 38169Keyerror: 0 [How to Solve]
- Python Pandas Error: KeyError: 0 [How to Solve]
- Python quote error: * * * keyerror: u ‘\ uxx’ [How to Solve]
- Flash cli encountered a keyerror “migrate” [How to Solve]
- How to Fix keyerror in Python dictionary lookup
- odoo Error: KeyError:‘ir.http‘ [How to Solve]
- Error in sitecustomize set PYTHONVERBOSE for traceback KeyError: ‘PYTHONPATH’
- How to Solve Automatic error keyerror:***‘
- [Solved] KeyError: ‘Transformer/encoderblock_0/MultiHeadDotProductAttention_1/query\\kernel is
- [Solved] PyTorch Error: TypeError: exceptions must derive from BaseException
- [Pytorch Error Solution] Pytorch distributed RuntimeError: Address already in use
- [Solved] Pytorch Error: RuntimeError: Error(s) in loading state_dict for Network: size mismatch
- [Solved] flash initializate database error: Keyerror: ‘migrate’
- [Solved] D455 Depth Camera Error: keyerror: ‘frame_ device_ t‘