Issue
I am trying to make my main.py
file concise so I wrote my Dataset
class in another py
file.
from torch.utils.data import DataLoader, Dataset
from sklearn.model_selection import train_test_split
from torch.nn.utils.rnn import pad_sequence
class mydata(Dataset):
def __init__(self, X, y):
self.X = torch.FloatTensor(X)
self.y = torch.FloatTensor(y)
def __len__(self):
return len(self.X)
def __getitem__(self, index):
y = self.y[index]
X = self.X[index]
return X,
When I try to import it, I got an import error.
ImportError: cannot import name 'mydata' from 'tools' (d:\A\Pycodes\tools.py)```
Solution
The problem is solved as tools.py
is restricted and probably a function already existed in the environment.
Answered By - Leo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.