ky_Pa
(ky_Pa)
March 11, 2020, 6:31am
1
What is the mistake?I checked and found no path errors. How to modify it? Thank you!
for step, (testdata, testlabel) in enumerate(src_data_loader):
testdata = make_variable(testdata)
testlabel = make_variable(testlabel.squeeze_())
src_dataset = scipy.io.loadmat('E:\\ADDA\\adda-lab-mat\\datasets\\lab_mat\\test_target_domain_sandy')
testdata = src_dataset['testdata']
testlabel = src_dataset['testlabel']
testdata = torch.from_numpy(testdata).float()
testlabel = torch.from_numpy(testlabel).long()
src_dataloader = torch.utils.data.DataLoader(
dataset=src_dataset,
batch_size=batch_size,
shuffle=True,
drop_last=True,
num_workers=1)
return src_dataloader
Could you redownload or recreate the data as it seems the file is not complete (truncated).
ky_Pa
(ky_Pa)
March 11, 2020, 7:43am
3
Is there any other possible cause of the error? The error persists after I re-download the file.
Oh, it seems you are trying to pass a mat
to the DataLoader
.
Could you try to create a TensorDataset
using the testdata
and testlabels
and pass this dataset to the DataLoader
?
ky_Pa
(ky_Pa)
March 11, 2020, 8:50am
5
This time it works, thank you very much! Does the Dataloader have to load a dataset? What if I need to load testdata and testlabel separately?
DataLoader
accepts Dataset
s and should also accept tensors.
However, I would recommend to wrap even tensors into a TensorDataset
.
As long as your testdata
and testlabel
are tensors, it should be fine.
ky_Pa
(ky_Pa)
March 11, 2020, 8:55am
7
OK, thank you for your patience.