I want to train a simple neural network on PyTorch using a personal database. This database is imported from an Excel file and stored in df.
One of the
Simply convert the pandas dataframe -> numpy array -> pytorch tensor. An example of this is described below:
import pandas as pd
import numpy as np
import torch
df = pd.read_csv('train.csv')
target = pd.DataFrame(df['target'])
del df['target']
train = data_utils.TensorDataset(torch.Tensor(np.array(df)), torch.Tensor(np.array(target)))
train_loader = data_utils.DataLoader(train, batch_size = 10, shuffle = True)
Hopefully, this will help you to create your own datasets using pytorch (Compatible with the latest version of pytorch).