I have a dataset composed of labels,features,adjacency matrices, laplacian graphs in numpy format.
I would like to build a torch.utils.data.data_utils.TensorDataset() and torch.utils.data.DataLoader() that can take labels,features,adjacency matrices, laplacian graphs.
To do so, l have tried the following
import numpy as np import torch.utils.data as data_utils # get the numpy data labels_train,features_train,adjacency_train,laplacian_train=train labels_test,features_test,adjacency_test,laplacian_test=test # expand dimension features_train=np.expand_dims(features_train,axis=0) features_test=np.expand_dims(features_test,axis=0) adjacency_train=np.expand_dims(adjacency_train,axis=0) adjacency_test=np.expand_dims(adjacency_test,axis=0) laplacian_train=np.expand_dims(laplacian_train,axis=0) laplacian_test=np.expand_dims(laplacian_test,axis=0) # convert numy data to torch labels_train=torch.from_numpy(labels_train) features_train=torch.from_numpy(features_train) adjacency_train=torch.from_numpy(adjacency_train) laplacian_train=torch.from_numpy(laplacian_train) labels_test=torch.from_numpy(labels_test) features_test=torch.from_numpy(features_test) adjacency_test=torch.from_numpy(adjacency_test) laplacian_test=torch.from_numpy(laplacian_test)
# l get stuck here
It doesn’t work because it’s supposed to take only two parameters features_train and labels_train only.
Is there any way to accept more than two parameters ?
What is my purpose ?
Once l have get train and test from
data_utils.TensorDataset() l would like to load my data as follow :
train_loader=data_utils.DataLoader(train) val_loader= data_utils.DataLoader(test)
It doesnt’ work because
DataLoader() is supposed to have only target and features_data (not adjacency matrices and laplacian).
I need this setup in order to do the following :
for i,(input,target,adjacency_matrix,laplacian) in enumerate(train_loader): # do my training
Thank you for you help