-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Deepcopy and pickling fails for modeling_outputs #8978
Copy link
Copy link
Closed
Description
Environment info
transformersversion: 4.0.0- Python version: 3.8
- PyTorch version (GPU?): 1.6.0
- Using GPU in script?: N/A
Who can help
To reproduce
Steps to reproduce the behavior:
>>> from transformers.modeling_outputs import BaseModelOutput
>>> import torch
>>> import copy
>>> x = BaseModelOutput(last_hidden_state=torch.ones(1,))
>>> z = copy.deepcopy(x)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/lib/python3.8/copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/opt/lib/python3.8/copy.py", line 263, in _reconstruct
y = func(*args)
TypeError: __init__() missing 1 required positional argument: 'last_hidden_state'
>>> import pickle
>>> obj = pickle.dumps(x)
>>> obj_loaded = pickle.loads(obj)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: __init__() missing 1 required positional argument: 'last_hidden_state'
Expected behavior
No failures when using deepcopy or pickle.dumps/pickle.loads
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels