Using your own dataset on PyTorch
I have a dataset in numpy format (actually, I just modified the CIFAR-10/MNIST datasets given on PyTorch). The dimensions of it consist with the dimensions a normal CNN expects. For example, if I write: print(our_dataset.shape, our_labels.shape) I get: (10000, 3, 32, 32) (10000,) which is fine. Now I cast the data info torch format using: <SCODE>train_data = torch.from_numpy(our_dataset)
our_labels = torch.from_numpy(our_labels)
<ECODE> encapsulate it into a TensorDataset: train = torch.utils.data.TensorDataset(train_data, our_labels) and finally into a DataLoader: trainloader = torch.utils.data.DataLoader(train, batch_size=128, shuffle=True) All fine here. Now I build the neural network, and then when I do the training, I get the error: TypeError: DoubleSpatialConvolutionMM_updateOutput received an invalid combination of arguments - got (int, torch.DoubleTensor, torch.DoubleTensor, torch.FloatTensor, torch.FloatTensor, torch.DoubleTensor, torch.DoubleTensor, long, long, int, int, int, int), but expected (int state, torch.DoubleTensor input, torch.DoubleTensor output, torch.DoubleTensor weight, [torch.DoubleTensor bias or None], torch.DoubleTensor finput, torch.DoubleTensor fgradInput, int kW, int kH, int dW, int dH, int padW, int padH) If I am working on cuda, then the error changes to: _cudnn_convolution_full_forward received an invalid combination of arguments - got (torch.cuda.DoubleTensor, torch.cuda.FloatTensor, torch.cuda.FloatTensor, torch.cuda.DoubleTensor, tuple, tuple, int, bool), but expected (torch.cuda.RealTensor input, torch.cuda.RealTensor weight, torch.cuda.RealTensor bias, torch.cuda.RealTensor output, std::vector<int> pad, std::vector<int> stride, int groups, bool benchmark) Anyone has seen these errors before? In addition, is the right way of using a new dataset by first casting it to torch format, then building a TensorDataset and finally a DataLoader?
Ismail_Elezi
sarthak1996
you need to cast your data to double in that case
edgarriba
If I type: print(our_dataset.dtype, our_labels.dtype) I get: float32 int64 I sent the data to cuda (and gave the Error in that case). However, if I don’t send the net (and data) to cuda, I get the other error that I posted in my original post. @edgarriba Well, the data is already in float.
Ismail_Elezi
right, but the error says that expect a DoubleTensor
edgarriba
sarthak1996
If I case the our_dataset to float32 and labels to int64, then the error changes to: multi-target not supported at /data/users/soumith/miniconda2/conda-bld/pytorch-0.1.7_1485444530918/work/torch/lib/THNN/generic/ClassNLLCriterion.c:20 but the shape of the labels is (10000,). Hmm, this is becoming weird.
Ismail_Elezi
sarthak1996
It seems that this works.
Ismail_Elezi
the version of 0.3.0 can well solve the problem of the problem of ‘received an invalid combination of arguments’
Shine_George