I am trying to create a data loader for my dataset. When I run it I am getting the above error.
My code is as:
import torch
import pandas as pd
from torch.utils.data import DataLoader, Dataset
data = pd.read_csv("data.csv")
data = data.to_numpy()
data = data[:,1:].astype('float64')

class MyDataset(Dataset):
    def __init__(self, data, transform = None):
        self.data = data
        self.transform = transform

    def __getitem__(self, index):
        return self.data[index]

    def __len__(self):
        return len(self.data)


data = torch.tensor(data)
test = data
dataset  = MyDataset(data)
train_loader  = DataLoader(dataset)

When I run the below. I am getting the error
" in __getitem__x = self.data[index], TypeError: ‘int’ object is not subscriptable
for epoch in range(1000):
    loss_sum = 0.0
    for i, x in enumerate(train_loader):
        optimizer.zero_grad()
        loss = -model.log_prob(x.to(args.device)).mean()
        loss.backward()
        optimizer.step()
        loss_sum += loss.detach().cpu().item()