input_size = 13
hidden1_size = 13
hidden2_size = 128
hidden3_size = 64
output_size = 30
class DNN(nn.Module):
def init(self, input_size, hidden1_size, hidden2_size, hidden3_size, output_size):
super(DNN, self).init()
self.fc1 = nn.Linear(input_size, hidden1_size)
self.relu1 = nn.ReLU()
self.fc2 = nn.Linear(hidden1_size, hidden2_size)
self.relu2 = nn.ReLU()
self.fc3 = nn.Linear(hidden2_size, hidden3_size)
self.relu3 = nn.ReLU()
self.fc4 = nn.Linear(hidden3_size, output_size)
self.relu4 = nn.ReLU()
def forward(self, x):
    out = self.fc1(x)
    out = self.relu1(out)
    out = self.fc2(out)
    out = self.relu2(out)
    out = self.fc3(out)
    out = self.relu3(out)
    out = self.fc4(out)
    out = self.relu4(out)
    return out

batch_size = 10
n_iterations = 50
no_eps = n_iterations / (13 / batch_size)
no_epochs = int(no_eps)
model = DNN(input_size, hidden1_size, hidden2_size, hidden3_size, output_size)
criterion = nn.CrossEntropyLoss()
learning_rate = 0.01
optimizer = torch.optim.SGD(model.parameters(), lr=learning_rate)
iter = 0
for epoch in range(no_epochs):
for i, (X_train, y_train) in enumerate(train_loader):
y_train = torch.empty(batch_size, dtype=torch.long).random_(output_size)
optimizer.zero_grad()
outputs = model(X_train)
loss = criterion(outputs, y_train)
loss.backward()
optimizer.step()
iter += 1
if iter % 500 == 0:
correct = 0
total = 0
for X_test, y_test in test_loader:
outputs = model(X_test)
pred = outputs.argmax(dim=1, keepdim=True)
total += y_test.size(0)
correct += pred.eq(y_test.view_as(pred)).sum().item()
accuracy = 100 * correct / total
print(‘Iteration: {}. Loss: {}. Accuracy: {}’.format(iter, loss.item(), accuracy))

The output start with Iteration 500 not 1 why !!!
Iteration: 500. Loss: 3.403779983520508. Accuracy: 0.2761323337093925
Iteration: 1000. Loss: 3.4060192108154297. Accuracy: 0.3276070990724763
Iteration: 1500. Loss: 3.416713237762451. Accuracy: 0.4173101012337052
Iteration: 2000. Loss: 3.402294635772705. Accuracy: 0.34867708074959347
Iteration: 2500. Loss: 3.3952858448028564. Accuracy: 0.2755100135754692
Iteration: 3000. Loss: 3.4023067951202393. Accuracy: 0.3158719194042085