I am trying to create a Dataloader using the built-in DataLoader class from a dataset created using the built-in Dataset class, the problem is that the tensor in the DataLoader reverts to reqiures_grad=False. I think the DataLoader class makes a copy or something, what might be the best way of going around this?.
_data=torch.tensor(newData).float();
lebels=torch.tensor(y_train).float();
data=torch.utils.data.TensorDataset(_data,lebels)
print("data shape: ", _data.shape);
print("Lebels shape : ", lebels.shape);
data=torch.utils.data.TensorDataset(data.requires_grad()
, lebels.requires_grad());
_data[0][0].requires_grad #outputs true
trainDataLoader = DataLoader(dataset=_data, batch_size=15, shuffle=True)
it = iter(trainDataLoader)
first = next(it)
first[0][0].requires_grad #outputs False