apply_func.py: from torchtext.legacy.data import Batch (#6211)
* Update apply_func.py The name Batch is no longer located under torchtext.data --Error message-- File "/home/daniel/py38/lib/python3.8/site-packages/pytorch_lightning/utilities/apply_func.py", line 25, in <module> from torchtext.data import Batch ImportError: cannot import name 'Batch' from 'torchtext.data' (/home/daniel/py38/lib/p ython3.8/site-packages/torchtext/data/__init__.py) You can fix this by changing line line 28 to: from torchtext.legacy.data import Batch * Update apply_func.py * Update apply_func.py * Update apply_func.py * Update apply_func.py * Update apply_func.py
This commit is contained in:
parent
0647340f3b
commit
ee5032a478
|
@ -23,9 +23,13 @@ import torch
|
|||
|
||||
from pytorch_lightning.utilities.exceptions import MisconfigurationException
|
||||
from pytorch_lightning.utilities.imports import _TORCHTEXT_AVAILABLE
|
||||
from pytorch_lightning.utilities.imports import _module_available
|
||||
|
||||
if _TORCHTEXT_AVAILABLE:
|
||||
from torchtext.data import Batch
|
||||
if _module_available("torchtext.legacy.data"):
|
||||
from torchtext.legacy.data import Batch
|
||||
else:
|
||||
from torchtext.data import Batch
|
||||
else:
|
||||
Batch = type(None)
|
||||
|
||||
|
|
Loading…
Reference in New Issue