DataLoader gives double instead of float?
<SCODE>X_train = torch.from_numpy(X_train)
Y_train = torch.from_numpy(Y_train)
X_test = torch.from_numpy(X_test)
Y_test = torch.from_numpy(Y_test)

[all dtypes torch.FloatTensor confirmed]

train = torch.utils.data.TensorDataset(X_train, Y_train)
trainloader = torch.utils.data.DataLoader(train, batch_size=BATCH_SIZE, shuffle=True)


train_iter = iter(trainloader)
data = train_iter.next()
x, y = data		
print y
<ECODE> And I get torch.DoubleTensor x is torch.FloatTensor
Veril
I can’t reproduce your issue. To resolve a problem we need a self-contained snippet that we can run.
apaszke
The following reproduces this. <SCODE>import numpy as np

import torch
import torch.utils.data


X_train = np.random.uniform(-1, 1, (1000,11)).astype(np.float32)
Y_train = np.hstack((np.zeros(500), np.ones(500))).astype(np.float32)

X_train = torch.from_numpy(X_train)
Y_train = torch.from_numpy(Y_train)


print X_train
print Y_train


train = torch.utils.data.TensorDataset(X_train, Y_train)
trainloader = torch.utils.data.DataLoader(train, batch_size=128, shuffle=True)


train_iter = iter(trainloader)
data = train_iter.next()
x, y = data		
print x
print y
<ECODE> Maybe this is intentional but I can’t figure out why make a float into a double in that context, and why only the second one.
Veril
<SCODE>Y_train = torch.from_numpy(Y_train).view(-1, 1)
<ECODE> <SCODE> return self.data_tensor.narrow(0, index, 1), self.target_tensor.narrow(0, index, 1)
<ECODE> should solve the issue by always returning Tensor and not numbers. Would this break something I’m not aware of? (Let me know if you want me to send a PR for that)
albanD
copy_ doesn’t care if it gets data in shape (batch) or (batch,) ? A quick test shows no changes in loss behavior. <SCODE>input = Variable(torch.FloatTensor(BATCH_SIZE, dims).cuda())
label = Variable(torch.FloatTensor(BATCH_SIZE).cuda())

x, y = train_iter.next()
input.data.resize_(x.size()).copy_(x)
label.data.resize_(x.size(0)).copy_(y)<ECODE>
Veril
albanD