PyTorch 导入 3D .mat 数据代码示例
import scipy.io as sio
from torch.utils.data import Dataset
class MatDataset(Dataset):
def __init__(self, file_name):
self.file_name = file_name
self.data = sio.loadmat(file_name)
def __len__(self):
return len(self.data)
def __getitem__(self, idx):
return torch.from_numpy(self.data[idx])
原文地址: https://www.cveoy.top/t/topic/llTa 著作权归作者所有。请勿转载和采集!