According to my understanding, DataLoader can be use to define batch_size+shuffle. I would like to use these DataLoader feature for my own dataset.
X = numpy[8000, 432] (8000 data, 432 features)
Y = numpy[8000, ]
I write this code to train my own dataset:
dataset = np.column_stack((self.X_train,self.Y_train))
train_loader = DataLoader(dataset=dataset,
                          batch_size=32,
                          shuffle=True,
                          num_workers=2)

self.model = self.Net(self.feature_size, self.n_layers, self.n_neurons)
        
self.model.train()
optimizer = optim.Adam(self.model.parameters(), lr = self.learning_rate)
loss_func = nn.MSELoss()

# Training step
for (X,Y) in train_loader:
    x, y = Variable(X), Variable(Y)
    optimizer.zero_grad()
            
    self.y_train = self.model(x)
    loss = loss_func(self.y_train, y)
            
    loss.backward()  #retain_graph=True
    optimizer.step()

Am I on the right track?