importing error default_collate is not defined
Question:
I tried to import default_collate
from torch.utils.data.dataloader
but it says that default_collate
does not exist, but another function does exist (_collate_fn_t
).
from torch.utils.data.dataloader import default_collate
from torch.utils.data.dataloader import _collate_fn_t
Are these commands are similar?
Answers:
The _collate_fn_t
is the type definition of a collate function in general, it is defined here as:
_collate_fn_t = Callable[[List[T]], Any]
default_collate
is the default collate function used by the DataLoader class.
Importing these is not equivalent, you should check your spelling and try again with:
from torch.utils.data.dataloader import default_collate
I tried to import default_collate
from torch.utils.data.dataloader
but it says that default_collate
does not exist, but another function does exist (_collate_fn_t
).
from torch.utils.data.dataloader import default_collate
from torch.utils.data.dataloader import _collate_fn_t
Are these commands are similar?
The _collate_fn_t
is the type definition of a collate function in general, it is defined here as:
_collate_fn_t = Callable[[List[T]], Any]
default_collate
is the default collate function used by the DataLoader class.
Importing these is not equivalent, you should check your spelling and try again with:
from torch.utils.data.dataloader import default_collate