I was trying to do a simple thing which was train a linear model with Stochastic Gradient Descent (SGD) using torch:
import numpy as np
import torch
from torch.
An alternative could be using pd.DataFrame.sample
train = pd.read_csv(TrainSetPath)
test = pd.read_csv(TestSetPath)
# use df.sample() to shuffle the data frame
train = train.sample(frac=1)
test = test.sample(frac=1)
for i in range(epochs):
for j in range(batch_per_epoch):
train_batch = train.sample(n=BatchSize, axis='index',replace=True)
y_train = train_batch['Target']
X_train = train_batch.drop(['Target'], axis=1)
# convert data frames to tensors and send them to GPU (if used)
X_train = torch.tensor(np.mat(X_train)).float().to(device)
y_train = torch.tensor(np.mat(y_train)).float().to(device)