I am a beginner here trying to use pytorch for classification where the features are all numeric values. I have been trying to follow other classification examples but they are either image or text which is not exactly what I want. I get the following error from the below code following a Kaggle Titanic Competition kernel:

RuntimeError: cannot unsqueeze empty tensor

```
import torch
import numpy as np
from torch.autograd import Variable
from torch.utils.data import Dataset, DataLoader
import pandas as pd
import torch.nn as nn
import torch.nn.functional as F
class Net(nn.Module):
def __init__(self):
super(Net, self).__init__()
self.i1 = nn.Linear(74, 128)
self.i1 = nn.Linear(128, 3)
# 3 possible labels for now
def forward(self, x):
x = self.i1(x)
x = F.dropout(x, p=0.1)
x = F.relu(x)
x = self.i2(x)
x = F.sigmoid(x)
return x
class NumberDataset(Dataset):
def __init__(self):
self.data = pd.read_csv('./data.csv', header=0, usecols=fields)
# Number of columns in data is 75
# Number of columns for self.x or input is 74
# Nunber of columns for self.y or target is 1
self.x = torch.from_numpy(np.asarray(self.data.iloc[:, :-1])).type(torch.FloatTensor)
self.y = torch.from_numpy(np.asarray(self.data.iloc[:, -1])).type(torch.LongTensor)
self.len = len(self.data)
def __getitem__(self, index):
return self.x[index], self.y[index]
def __len__(self):
return self.len
# returns 640
if __name__ == '__main__':
dataset = NumberDataset()
train_loader = DataLoader(dataset=dataset, batch_size=128, shuffle=True)
net = Net()
batch_size = 128
num_epochs = 10000
learning_rate = 0.01
batch_no = dataset.len // batch_size
criterion = nn.CrossEntropyLoss()
optimizer = torch.optim.Adam(net.parameters(), lr=learning_rate)
for i, data in enumerate(train_loader, 0):
# get the inputs and labels from data loader
inputs, labels = data
for epoch in range(num_epochs):
if epoch % 5 == 0:
print('Epoch {}'.format(epoch + 1))
# Mini batch learning
for i in range(batch_no):
start = i * batch_size
end = start + batch_size
x_var = Variable(inputs[start:end])
y_var = Variable(abels[start:end])
# Forward + Backward + Optimize
optimizer.zero_grad()
ypred_var = net(x_var)
loss = criterion(ypred_var, y_var)
loss.backward()
optimizer.step()
```

Where exactly am I going wrong? Is this approach right for a feed forward neural network?