MLP With Different Loss Functions¶
Imports¶
In [ ]:
import matplotlib.pyplot as plt
import pandas as pd
import torch
%matplotlib inline
In [13]:
import time
import numpy as np
from torchvision import datasets
from torchvision import transforms
from torch.utils.data import DataLoader
import torch.nn.functional as F
import torch
Settings and Dataset¶
In [15]:
!wget www.di.ens.fr/~lelarge/MNIST.tar.gz
!tar -zxvf MNIST.tar.gz
##########################
### SETTINGS
##########################
RANDOM_SEED = 1
BATCH_SIZE = 100
NUM_EPOCHS = 100
DEVICE = torch.device(‘cuda:0’ if torch.cuda.is_available() else ‘cpu’)
##########################
### MNIST DATASET
##########################
# Note transforms.ToTensor() scales input images
# to 0-1 range
train_dataset = datasets.MNIST(root=’./’,
train=True,
transform=transforms.ToTensor(),
download=True)
test_dataset = datasets.MNIST(root=’./’,
train=False,
transform=transforms.ToTensor())
train_loader = DataLoader(dataset=train_dataset,
batch_size=BATCH_SIZE,
shuffle=True)
test_loader = DataLoader(dataset=test_dataset,
batch_size=BATCH_SIZE,
shuffle=False)
# Checking the dataset
for images, labels in train_loader:
print(‘Image batch dimensions:’, images.shape)
print(‘Image label dimensions:’, labels.shape)
break
–2021-03-19 01:10:30– http://www.di.ens.fr/~lelarge/MNIST.tar.gz
Resolving www.di.ens.fr (www.di.ens.fr)… 129.199.99.14
Connecting to www.di.ens.fr (www.di.ens.fr)|129.199.99.14|:80… connected.
HTTP request sent, awaiting response… 302 Found
Location: https://www.di.ens.fr/~lelarge/MNIST.tar.gz [following]
–2021-03-19 01:10:31– https://www.di.ens.fr/~lelarge/MNIST.tar.gz
Connecting to www.di.ens.fr (www.di.ens.fr)|129.199.99.14|:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘MNIST.tar.gz’
MNIST.tar.gz [ <=> ] 33.20M 6.74MB/s in 5.7s
2021-03-19 01:10:38 (5.84 MB/s) – ‘MNIST.tar.gz’ saved [34813078]
MNIST/
MNIST/raw/
MNIST/raw/train-labels-idx1-ubyte
MNIST/raw/t10k-labels-idx1-ubyte.gz
MNIST/raw/t10k-labels-idx1-ubyte
MNIST/raw/t10k-images-idx3-ubyte.gz
MNIST/raw/train-images-idx3-ubyte
MNIST/raw/train-labels-idx1-ubyte.gz
MNIST/raw/t10k-images-idx3-ubyte
MNIST/raw/train-images-idx3-ubyte.gz
MNIST/processed/
MNIST/processed/training.pt
MNIST/processed/test.pt
Image batch dimensions: torch.Size([100, 1, 28, 28])
Image label dimensions: torch.Size([100])
In [16]:
def to_onehot(y, num_classes):
y_onehot = torch.FloatTensor(y.size(0), num_classes)
y_onehot.zero_()
tmp = y.view(-1, 1).long().to(torch.device(‘cpu’))
y_onehot.scatter_(1, tmp, 1).float()
return y_onehot
Model¶
In [ ]:
class MlpSigmoidMSE(torch.nn.Module):
def __init__(self, num_features, num_hidden, num_classes):
super(MlpSigmoidMSE, self).__init__()
self.num_classes = num_classes
### 1st hidden layer
self.linear_1 = torch.nn.Linear(num_features, num_hidden)
self.linear_1.weight.detach().normal_(0.0, 0.1)
self.linear_1.bias.detach().zero_()
### Output layer
self.linear_out = torch.nn.Linear(num_hidden, num_classes)
self.linear_out.weight.detach().normal_(0.0, 0.1)
self.linear_out.bias.detach().zero_()
def forward(self, x):
out = self.linear_1(x)
out = torch.sigmoid(out)
logits = self.linear_out(out)
probas = torch.softmax(logits, dim=1)
return logits, probas
#################################
### Model Initialization
#################################
torch.manual_seed(RANDOM_SEED)
model = MlpSigmoidMSE(num_features=28*28,
num_hidden=100,
num_classes=10)
model = model.to(DEVICE)
optimizer = torch.optim.SGD(model.parameters(), lr=0.1)
#################################
### Training
#################################
##Make your code changes here###
def compute_loss(net, data_loader):
curr_loss = 0.
with torch.no_grad():
for cnt, (features, targets) in enumerate(data_loader):
features = features.view(-1, 28*28).to(DEVICE)
targets = targets.to(DEVICE)
logits, probas = net.forward(features)
loss = F.nll_loss(torch.log(probas), targets)
curr_loss += loss
return float(curr_loss)/cnt
start_time = time.time()
minibatch_cost = []
epoch_cost = []
for epoch in range(NUM_EPOCHS):
model.train()
for batch_idx, (features, targets) in enumerate(train_loader):
features = features.view(-1, 28*28).to(DEVICE)
targets = targets.to(DEVICE)
### FORWARD AND BACK PROP
logits, probas = model(features)
#y_onehot = to_onehot(targets, model.num_classes).to(DEVICE)
cost = F.nll_loss(torch.log(probas), targets)
optimizer.zero_grad()
cost.backward()
minibatch_cost.append(cost)
### UPDATE MODEL PARAMETERS
optimizer.step()
### LOGGING
if not batch_idx % 50:
print (‘Epoch: %03d/%03d | Batch %03d/%03d | Cost: %.4f’
%(epoch+1, NUM_EPOCHS, batch_idx,
len(train_loader), cost))
cost = compute_loss(model, train_loader)
epoch_cost.append(cost)
print(‘Epoch: %03d/%03d Train Cost: %.4f’ % (
epoch+1, NUM_EPOCHS, cost))
print(‘Time elapsed: %.2f min’ % ((time.time() – start_time)/60))
print(‘Total Training Time: %.2f min’ % ((time.time() – start_time)/60))
Epoch: 001/100 | Batch 000/600 | Cost: 2.5084
Epoch: 001/100 | Batch 050/600 | Cost: 1.8427
Epoch: 001/100 | Batch 100/600 | Cost: 1.5315
Epoch: 001/100 | Batch 150/600 | Cost: 1.1718
Epoch: 001/100 | Batch 200/600 | Cost: 0.9109
Epoch: 001/100 | Batch 250/600 | Cost: 0.8646
Epoch: 001/100 | Batch 300/600 | Cost: 0.8037
Epoch: 001/100 | Batch 350/600 | Cost: 0.6273
Epoch: 001/100 | Batch 400/600 | Cost: 0.6740
Epoch: 001/100 | Batch 450/600 | Cost: 0.6362
Epoch: 001/100 | Batch 500/600 | Cost: 0.4912
Epoch: 001/100 | Batch 550/600 | Cost: 0.4527
Epoch: 001/100 Train Cost: 0.4979
Time elapsed: 0.25 min
Epoch: 002/100 | Batch 000/600 | Cost: 0.5251
Epoch: 002/100 | Batch 050/600 | Cost: 0.5323
Epoch: 002/100 | Batch 100/600 | Cost: 0.5432
Epoch: 002/100 | Batch 150/600 | Cost: 0.3142
Epoch: 002/100 | Batch 200/600 | Cost: 0.3629
Epoch: 002/100 | Batch 250/600 | Cost: 0.5859
Epoch: 002/100 | Batch 300/600 | Cost: 0.4204
Epoch: 002/100 | Batch 350/600 | Cost: 0.3396
Epoch: 002/100 | Batch 400/600 | Cost: 0.5113
Epoch: 002/100 | Batch 450/600 | Cost: 0.3750
Epoch: 002/100 | Batch 500/600 | Cost: 0.3116
Epoch: 002/100 | Batch 550/600 | Cost: 0.4173
Epoch: 002/100 Train Cost: 0.3758
Time elapsed: 0.50 min
Epoch: 003/100 | Batch 000/600 | Cost: 0.3656
Epoch: 003/100 | Batch 050/600 | Cost: 0.3162
Epoch: 003/100 | Batch 100/600 | Cost: 0.2925
Epoch: 003/100 | Batch 150/600 | Cost: 0.4613
Epoch: 003/100 | Batch 200/600 | Cost: 0.4184
Epoch: 003/100 | Batch 250/600 | Cost: 0.5171
Epoch: 003/100 | Batch 300/600 | Cost: 0.3936
Epoch: 003/100 | Batch 350/600 | Cost: 0.3857
Epoch: 003/100 | Batch 400/600 | Cost: 0.4068
Epoch: 003/100 | Batch 450/600 | Cost: 0.4339
Epoch: 003/100 | Batch 500/600 | Cost: 0.3854
Epoch: 003/100 | Batch 550/600 | Cost: 0.4515
Epoch: 003/100 Train Cost: 0.3306
Time elapsed: 0.74 min
Epoch: 004/100 | Batch 000/600 | Cost: 0.2835
Epoch: 004/100 | Batch 050/600 | Cost: 0.2887
Epoch: 004/100 | Batch 100/600 | Cost: 0.3390
Epoch: 004/100 | Batch 150/600 | Cost: 0.3641
Epoch: 004/100 | Batch 200/600 | Cost: 0.2254
Epoch: 004/100 | Batch 250/600 | Cost: 0.3255
Epoch: 004/100 | Batch 300/600 | Cost: 0.2185
Epoch: 004/100 | Batch 350/600 | Cost: 0.3543
Epoch: 004/100 | Batch 400/600 | Cost: 0.4991
Epoch: 004/100 | Batch 450/600 | Cost: 0.2679
Epoch: 004/100 | Batch 500/600 | Cost: 0.2311
Epoch: 004/100 | Batch 550/600 | Cost: 0.2280
Epoch: 004/100 Train Cost: 0.3041
Time elapsed: 1.00 min
Epoch: 005/100 | Batch 000/600 | Cost: 0.3634
Epoch: 005/100 | Batch 050/600 | Cost: 0.2838
Epoch: 005/100 | Batch 100/600 | Cost: 0.3336
Epoch: 005/100 | Batch 150/600 | Cost: 0.2085
Epoch: 005/100 | Batch 200/600 | Cost: 0.2978
Epoch: 005/100 | Batch 250/600 | Cost: 0.4452
Epoch: 005/100 | Batch 300/600 | Cost: 0.2988
Epoch: 005/100 | Batch 350/600 | Cost: 0.3559
Epoch: 005/100 | Batch 400/600 | Cost: 0.4635
Epoch: 005/100 | Batch 450/600 | Cost: 0.2219
Epoch: 005/100 | Batch 500/600 | Cost: 0.2293
Epoch: 005/100 | Batch 550/600 | Cost: 0.2673
Epoch: 005/100 Train Cost: 0.2873
Time elapsed: 1.24 min
Epoch: 006/100 | Batch 000/600 | Cost: 0.2381
Epoch: 006/100 | Batch 050/600 | Cost: 0.2655
Epoch: 006/100 | Batch 100/600 | Cost: 0.2408
Epoch: 006/100 | Batch 150/600 | Cost: 0.2293
Epoch: 006/100 | Batch 200/600 | Cost: 0.1550
Epoch: 006/100 | Batch 250/600 | Cost: 0.2278
Epoch: 006/100 | Batch 300/600 | Cost: 0.3062
Epoch: 006/100 | Batch 350/600 | Cost: 0.2895
Epoch: 006/100 | Batch 400/600 | Cost: 0.3168
Epoch: 006/100 | Batch 450/600 | Cost: 0.3467
Epoch: 006/100 | Batch 500/600 | Cost: 0.3975
Epoch: 006/100 | Batch 550/600 | Cost: 0.2027
Epoch: 006/100 Train Cost: 0.2696
Time elapsed: 1.48 min
Epoch: 007/100 | Batch 000/600 | Cost: 0.1689
Epoch: 007/100 | Batch 050/600 | Cost: 0.2424
Epoch: 007/100 | Batch 100/600 | Cost: 0.2946
Epoch: 007/100 | Batch 150/600 | Cost: 0.3725
Epoch: 007/100 | Batch 200/600 | Cost: 0.1860
Epoch: 007/100 | Batch 250/600 | Cost: 0.2772
Epoch: 007/100 | Batch 300/600 | Cost: 0.2552
Epoch: 007/100 | Batch 350/600 | Cost: 0.3087
Epoch: 007/100 | Batch 400/600 | Cost: 0.1901
Epoch: 007/100 | Batch 450/600 | Cost: 0.1842
Epoch: 007/100 | Batch 500/600 | Cost: 0.3009
Epoch: 007/100 | Batch 550/600 | Cost: 0.2827
Epoch: 007/100 Train Cost: 0.2570
Time elapsed: 1.73 min
Epoch: 008/100 | Batch 000/600 | Cost: 0.3012
Epoch: 008/100 | Batch 050/600 | Cost: 0.2296
Epoch: 008/100 | Batch 100/600 | Cost: 0.3714
Epoch: 008/100 | Batch 150/600 | Cost: 0.2811
Epoch: 008/100 | Batch 200/600 | Cost: 0.2681
Epoch: 008/100 | Batch 250/600 | Cost: 0.3863
Epoch: 008/100 | Batch 300/600 | Cost: 0.2550
Epoch: 008/100 | Batch 350/600 | Cost: 0.2403
Epoch: 008/100 | Batch 400/600 | Cost: 0.2992
Epoch: 008/100 | Batch 450/600 | Cost: 0.2109
Epoch: 008/100 | Batch 500/600 | Cost: 0.2320
Epoch: 008/100 | Batch 550/600 | Cost: 0.1799
Epoch: 008/100 Train Cost: 0.2451
Time elapsed: 1.98 min
Epoch: 009/100 | Batch 000/600 | Cost: 0.3631
Epoch: 009/100 | Batch 050/600 | Cost: 0.3259
Epoch: 009/100 | Batch 100/600 | Cost: 0.2794
Epoch: 009/100 | Batch 150/600 | Cost: 0.2031
Epoch: 009/100 | Batch 200/600 | Cost: 0.2271
Epoch: 009/100 | Batch 250/600 | Cost: 0.4515
Epoch: 009/100 | Batch 300/600 | Cost: 0.2139
Epoch: 009/100 | Batch 350/600 | Cost: 0.5466
Epoch: 009/100 | Batch 400/600 | Cost: 0.2328
Epoch: 009/100 | Batch 450/600 | Cost: 0.3042
Epoch: 009/100 | Batch 500/600 | Cost: 0.2403
Epoch: 009/100 | Batch 550/600 | Cost: 0.1352
Epoch: 009/100 Train Cost: 0.2347
Time elapsed: 2.22 min
Epoch: 010/100 | Batch 000/600 | Cost: 0.1620
Epoch: 010/100 | Batch 050/600 | Cost: 0.2208
Epoch: 010/100 | Batch 100/600 | Cost: 0.2688
Epoch: 010/100 | Batch 150/600 | Cost: 0.1686
Epoch: 010/100 | Batch 200/600 | Cost: 0.2095
Epoch: 010/100 | Batch 250/600 | Cost: 0.4605
Epoch: 010/100 | Batch 300/600 | Cost: 0.1723
Epoch: 010/100 | Batch 350/600 | Cost: 0.2466
Epoch: 010/100 | Batch 400/600 | Cost: 0.2410
Epoch: 010/100 | Batch 450/600 | Cost: 0.1625
Epoch: 010/100 | Batch 500/600 | Cost: 0.2127
Epoch: 010/100 | Batch 550/600 | Cost: 0.1842
Epoch: 010/100 Train Cost: 0.2257
Time elapsed: 2.47 min
Epoch: 011/100 | Batch 000/600 | Cost: 0.2414
Epoch: 011/100 | Batch 050/600 | Cost: 0.1752
Epoch: 011/100 | Batch 100/600 | Cost: 0.1892
Epoch: 011/100 | Batch 150/600 | Cost: 0.2749
Epoch: 011/100 | Batch 200/600 | Cost: 0.2031
Epoch: 011/100 | Batch 250/600 | Cost: 0.3603
Epoch: 011/100 | Batch 300/600 | Cost: 0.1587
Epoch: 011/100 | Batch 350/600 | Cost: 0.2085
Epoch: 011/100 | Batch 400/600 | Cost: 0.1758
Epoch: 011/100 | Batch 450/600 | Cost: 0.2162
Epoch: 011/100 | Batch 500/600 | Cost: 0.1707
Epoch: 011/100 | Batch 550/600 | Cost: 0.3225
Epoch: 011/100 Train Cost: 0.2164
Time elapsed: 2.71 min
Epoch: 012/100 | Batch 000/600 | Cost: 0.2094
Epoch: 012/100 | Batch 050/600 | Cost: 0.1386
Epoch: 012/100 | Batch 100/600 | Cost: 0.2329
Epoch: 012/100 | Batch 150/600 | Cost: 0.1185
Epoch: 012/100 | Batch 200/600 | Cost: 0.2021
Epoch: 012/100 | Batch 250/600 | Cost: 0.2477
Epoch: 012/100 | Batch 300/600 | Cost: 0.1520
Epoch: 012/100 | Batch 350/600 | Cost: 0.3098
Epoch: 012/100 | Batch 400/600 | Cost: 0.2454
Epoch: 012/100 | Batch 450/600 | Cost: 0.2764
Epoch: 012/100 | Batch 500/600 | Cost: 0.1900
Epoch: 012/100 | Batch 550/600 | Cost: 0.2213
Epoch: 012/100 Train Cost: 0.2083
Time elapsed: 2.96 min
Epoch: 013/100 | Batch 000/600 | Cost: 0.2732
Epoch: 013/100 | Batch 050/600 | Cost: 0.1764
Epoch: 013/100 | Batch 100/600 | Cost: 0.3136
Epoch: 013/100 | Batch 150/600 | Cost: 0.1983
Epoch: 013/100 | Batch 200/600 | Cost: 0.1081
Epoch: 013/100 | Batch 250/600 | Cost: 0.1971
Epoch: 013/100 | Batch 300/600 | Cost: 0.3835
Epoch: 013/100 | Batch 350/600 | Cost: 0.2541
Epoch: 013/100 | Batch 400/600 | Cost: 0.3476
Epoch: 013/100 | Batch 450/600 | Cost: 0.1515
Epoch: 013/100 | Batch 500/600 | Cost: 0.4162
Epoch: 013/100 | Batch 550/600 | Cost: 0.2541
Epoch: 013/100 Train Cost: 0.2020
Time elapsed: 3.20 min
Epoch: 014/100 | Batch 000/600 | Cost: 0.1157
Epoch: 014/100 | Batch 050/600 | Cost: 0.2305
Epoch: 014/100 | Batch 100/600 | Cost: 0.2215
Epoch: 014/100 | Batch 150/600 | Cost: 0.1821
Epoch: 014/100 | Batch 200/600 | Cost: 0.2768
Epoch: 014/100 | Batch 250/600 | Cost: 0.2704
Epoch: 014/100 | Batch 300/600 | Cost: 0.1683
Epoch: 014/100 | Batch 350/600 | Cost: 0.1918
Epoch: 014/100 | Batch 400/600 | Cost: 0.1763
Epoch: 014/100 | Batch 450/600 | Cost: 0.2902
Epoch: 014/100 | Batch 500/600 | Cost: 0.2474
Epoch: 014/100 | Batch 550/600 | Cost: 0.2698
Epoch: 014/100 Train Cost: 0.1940
Time elapsed: 3.44 min
Epoch: 015/100 | Batch 000/600 | Cost: 0.1988
Epoch: 015/100 | Batch 050/600 | Cost: 0.2530
Epoch: 015/100 | Batch 100/600 | Cost: 0.2249
Epoch: 015/100 | Batch 150/600 | Cost: 0.1491
Epoch: 015/100 | Batch 200/600 | Cost: 0.1440
Epoch: 015/100 | Batch 250/600 | Cost: 0.2322
Epoch: 015/100 | Batch 300/600 | Cost: 0.1803
Epoch: 015/100 | Batch 350/600 | Cost: 0.2334
Epoch: 015/100 | Batch 400/600 | Cost: 0.1644
Epoch: 015/100 | Batch 450/600 | Cost: 0.1320
Epoch: 015/100 | Batch 500/600 | Cost: 0.2613
Epoch: 015/100 | Batch 550/600 | Cost: 0.1511
Epoch: 015/100 Train Cost: 0.1877
Time elapsed: 3.69 min
Epoch: 016/100 | Batch 000/600 | Cost: 0.1386
Epoch: 016/100 | Batch 050/600 | Cost: 0.1607
Epoch: 016/100 | Batch 100/600 | Cost: 0.1405
Epoch: 016/100 | Batch 150/600 | Cost: 0.1236
Epoch: 016/100 | Batch 200/600 | Cost: 0.1406
Epoch: 016/100 | Batch 250/600 | Cost: 0.2605
Epoch: 016/100 | Batch 300/600 | Cost: 0.2105
Epoch: 016/100 | Batch 350/600 | Cost: 0.2265
Epoch: 016/100 | Batch 400/600 | Cost: 0.2865
Epoch: 016/100 | Batch 450/600 | Cost: 0.3034
Epoch: 016/100 | Batch 500/600 | Cost: 0.2379
Epoch: 016/100 | Batch 550/600 | Cost: 0.1278
Epoch: 016/100 Train Cost: 0.1820
Time elapsed: 3.94 min
Epoch: 017/100 | Batch 000/600 | Cost: 0.1500
Epoch: 017/100 | Batch 050/600 | Cost: 0.1757
Epoch: 017/100 | Batch 100/600 | Cost: 0.1157
Epoch: 017/100 | Batch 150/600 | Cost: 0.1477
Epoch: 017/100 | Batch 200/600 | Cost: 0.1281
Epoch: 017/100 | Batch 250/600 | Cost: 0.1271
Epoch: 017/100 | Batch 300/600 | Cost: 0.3230
Epoch: 017/100 | Batch 350/600 | Cost: 0.1841
Epoch: 017/100 | Batch 400/600 | Cost: 0.1693
Epoch: 017/100 | Batch 450/600 | Cost: 0.2347
Epoch: 017/100 | Batch 500/600 | Cost: 0.1735
Epoch: 017/100 | Batch 550/600 | Cost: 0.1036
Epoch: 017/100 Train Cost: 0.1762
Time elapsed: 4.20 min
Epoch: 018/100 | Batch 000/600 | Cost: 0.1423
Epoch: 018/100 | Batch 050/600 | Cost: 0.1828
Epoch: 018/100 | Batch 100/600 | Cost: 0.2101
Epoch: 018/100 | Batch 150/600 | Cost: 0.1648
Epoch: 018/100 | Batch 200/600 | Cost: 0.1174
Epoch: 018/100 | Batch 250/600 | Cost: 0.1952
Epoch: 018/100 | Batch 300/600 | Cost: 0.2140
Epoch: 018/100 | Batch 350/600 | Cost: 0.1341
Epoch: 018/100 | Batch 400/600 | Cost: 0.2004
Epoch: 018/100 | Batch 450/600 | Cost: 0.1307
Epoch: 018/100 | Batch 500/600 | Cost: 0.2666
Epoch: 018/100 | Batch 550/600 | Cost: 0.1553
Epoch: 018/100 Train Cost: 0.1704
Time elapsed: 4.47 min
Epoch: 019/100 | Batch 000/600 | Cost: 0.3805
Epoch: 019/100 | Batch 050/600 | Cost: 0.1992
Epoch: 019/100 | Batch 100/600 | Cost: 0.1420
Epoch: 019/100 | Batch 150/600 | Cost: 0.2250
Epoch: 019/100 | Batch 200/600 | Cost: 0.1148
Epoch: 019/100 | Batch 250/600 | Cost: 0.1196
Epoch: 019/100 | Batch 300/600 | Cost: 0.1535
Epoch: 019/100 | Batch 350/600 | Cost: 0.1799
Epoch: 019/100 | Batch 400/600 | Cost: 0.1097
Epoch: 019/100 | Batch 450/600 | Cost: 0.1211
Epoch: 019/100 | Batch 500/600 | Cost: 0.1879
Epoch: 019/100 | Batch 550/600 | Cost: 0.1481
Epoch: 019/100 Train Cost: 0.1656
Time elapsed: 4.73 min
Epoch: 020/100 | Batch 000/600 | Cost: 0.1409
Epoch: 020/100 | Batch 050/600 | Cost: 0.1300
Epoch: 020/100 | Batch 100/600 | Cost: 0.2522
Epoch: 020/100 | Batch 150/600 | Cost: 0.2633
Epoch: 020/100 | Batch 200/600 | Cost: 0.2089
Epoch: 020/100 | Batch 250/600 | Cost: 0.2762
Epoch: 020/100 | Batch 300/600 | Cost: 0.1109
Epoch: 020/100 | Batch 350/600 | Cost: 0.2544
Epoch: 020/100 | Batch 400/600 | Cost: 0.1923
Epoch: 020/100 | Batch 450/600 | Cost: 0.1726
Epoch: 020/100 | Batch 500/600 | Cost: 0.0913
Epoch: 020/100 | Batch 550/600 | Cost: 0.1428
Epoch: 020/100 Train Cost: 0.1614
Time elapsed: 4.99 min
Epoch: 021/100 | Batch 000/600 | Cost: 0.2537
Epoch: 021/100 | Batch 050/600 | Cost: 0.1751
Epoch: 021/100 | Batch 100/600 | Cost: 0.1352
Epoch: 021/100 | Batch 150/600 | Cost: 0.1559
Epoch: 021/100 | Batch 200/600 | Cost: 0.2192
Epoch: 021/100 | Batch 250/600 | Cost: 0.1681
Epoch: 021/100 | Batch 300/600 | Cost: 0.1248
Epoch: 021/100 | Batch 350/600 | Cost: 0.1591
Epoch: 021/100 | Batch 400/600 | Cost: 0.0657
Epoch: 021/100 | Batch 450/600 | Cost: 0.1563
Epoch: 021/100 | Batch 500/600 | Cost: 0.1509
Epoch: 021/100 | Batch 550/600 | Cost: 0.2246
Epoch: 021/100 Train Cost: 0.1560
Time elapsed: 5.26 min
Epoch: 022/100 | Batch 000/600 | Cost: 0.1697
Epoch: 022/100 | Batch 050/600 | Cost: 0.1565
Epoch: 022/100 | Batch 100/600 | Cost: 0.1902
Epoch: 022/100 | Batch 150/600 | Cost: 0.1699
Epoch: 022/100 | Batch 200/600 | Cost: 0.1792
Epoch: 022/100 | Batch 250/600 | Cost: 0.2705
Epoch: 022/100 | Batch 300/600 | Cost: 0.1391
Epoch: 022/100 | Batch 350/600 | Cost: 0.1100
Epoch: 022/100 | Batch 400/600 | Cost: 0.0859
Epoch: 022/100 | Batch 450/600 | Cost: 0.2078
Epoch: 022/100 | Batch 500/600 | Cost: 0.0721
Epoch: 022/100 | Batch 550/600 | Cost: 0.2467
Epoch: 022/100 Train Cost: 0.1518
Time elapsed: 5.53 min
Epoch: 023/100 | Batch 000/600 | Cost: 0.1077
Epoch: 023/100 | Batch 050/600 | Cost: 0.1415
Epoch: 023/100 | Batch 100/600 | Cost: 0.1481
Epoch: 023/100 | Batch 150/600 | Cost: 0.0687
Epoch: 023/100 | Batch 200/600 | Cost: 0.1305
Epoch: 023/100 | Batch 250/600 | Cost: 0.2226
Epoch: 023/100 | Batch 300/600 | Cost: 0.1178
Epoch: 023/100 | Batch 350/600 | Cost: 0.0713
Epoch: 023/100 | Batch 400/600 | Cost: 0.1263
Epoch: 023/100 | Batch 450/600 | Cost: 0.1055
Epoch: 023/100 | Batch 500/600 | Cost: 0.0584
Epoch: 023/100 | Batch 550/600 | Cost: 0.1681
Epoch: 023/100 Train Cost: 0.1480
Time elapsed: 5.79 min
Epoch: 024/100 | Batch 000/600 | Cost: 0.1204
Epoch: 024/100 | Batch 050/600 | Cost: 0.2067
Epoch: 024/100 | Batch 100/600 | Cost: 0.1587
Epoch: 024/100 | Batch 150/600 | Cost: 0.1322
Epoch: 024/100 | Batch 200/600 | Cost: 0.0978
Epoch: 024/100 | Batch 250/600 | Cost: 0.1341
Epoch: 024/100 | Batch 300/600 | Cost: 0.1544
Epoch: 024/100 | Batch 350/600 | Cost: 0.2112
Epoch: 024/100 | Batch 400/600 | Cost: 0.2112
Epoch: 024/100 | Batch 450/600 | Cost: 0.1981
Epoch: 024/100 | Batch 500/600 | Cost: 0.1656
Epoch: 024/100 | Batch 550/600 | Cost: 0.1547
Epoch: 024/100 Train Cost: 0.1453
Time elapsed: 6.06 min
Epoch: 025/100 | Batch 000/600 | Cost: 0.1436
Epoch: 025/100 | Batch 050/600 | Cost: 0.1205
Epoch: 025/100 | Batch 100/600 | Cost: 0.1424
Epoch: 025/100 | Batch 150/600 | Cost: 0.0971
Epoch: 025/100 | Batch 200/600 | Cost: 0.1655
Epoch: 025/100 | Batch 250/600 | Cost: 0.1499
Epoch: 025/100 | Batch 300/600 | Cost: 0.1498
Epoch: 025/100 | Batch 350/600 | Cost: 0.0542
Epoch: 025/100 | Batch 400/600 | Cost: 0.1110
Epoch: 025/100 | Batch 450/600 | Cost: 0.1833
Epoch: 025/100 | Batch 500/600 | Cost: 0.1006
Epoch: 025/100 | Batch 550/600 | Cost: 0.1876
Epoch: 025/100 Train Cost: 0.1400
Time elapsed: 6.32 min
Epoch: 026/100 | Batch 000/600 | Cost: 0.1491
Epoch: 026/100 | Batch 050/600 | Cost: 0.1545
Epoch: 026/100 | Batch 100/600 | Cost: 0.1245
Epoch: 026/100 | Batch 150/600 | Cost: 0.0866
Epoch: 026/100 | Batch 200/600 | Cost: 0.0692
Epoch: 026/100 | Batch 250/600 | Cost: 0.1400
Epoch: 026/100 | Batch 300/600 | Cost: 0.0761
Epoch: 026/100 | Batch 350/600 | Cost: 0.0898
Epoch: 026/100 | Batch 400/600 | Cost: 0.1235
Epoch: 026/100 | Batch 450/600 | Cost: 0.1670
Epoch: 026/100 | Batch 500/600 | Cost: 0.1349
Epoch: 026/100 | Batch 550/600 | Cost: 0.1450
Epoch: 026/100 Train Cost: 0.1363
Time elapsed: 6.59 min
Epoch: 027/100 | Batch 000/600 | Cost: 0.0817
Epoch: 027/100 | Batch 050/600 | Cost: 0.0873
Epoch: 027/100 | Batch 100/600 | Cost: 0.0963
Epoch: 027/100 | Batch 150/600 | Cost: 0.1128
Epoch: 027/100 | Batch 200/600 | Cost: 0.1035
Epoch: 027/100 | Batch 250/600 | Cost: 0.0948
Epoch: 027/100 | Batch 300/600 | Cost: 0.1058
Epoch: 027/100 | Batch 350/600 | Cost: 0.2765
Epoch: 027/100 | Batch 400/600 | Cost: 0.2618
Epoch: 027/100 | Batch 450/600 | Cost: 0.0964
Epoch: 027/100 | Batch 500/600 | Cost: 0.1180
Epoch: 027/100 | Batch 550/600 | Cost: 0.1836
Epoch: 027/100 Train Cost: 0.1338
Time elapsed: 6.86 min
Epoch: 028/100 | Batch 000/600 | Cost: 0.1059
Epoch: 028/100 | Batch 050/600 | Cost: 0.1719
Epoch: 028/100 | Batch 100/600 | Cost: 0.0831
Epoch: 028/100 | Batch 150/600 | Cost: 0.1497
Epoch: 028/100 | Batch 200/600 | Cost: 0.2321
Epoch: 028/100 | Batch 250/600 | Cost: 0.1170
Epoch: 028/100 | Batch 300/600 | Cost: 0.1854
Epoch: 028/100 | Batch 350/600 | Cost: 0.2190
Epoch: 028/100 | Batch 400/600 | Cost: 0.1036
Epoch: 028/100 | Batch 450/600 | Cost: 0.1427
Epoch: 028/100 | Batch 500/600 | Cost: 0.0918
Epoch: 028/100 | Batch 550/600 | Cost: 0.1155
Epoch: 028/100 Train Cost: 0.1298
Time elapsed: 7.13 min
Epoch: 029/100 | Batch 000/600 | Cost: 0.0911
Epoch: 029/100 | Batch 050/600 | Cost: 0.0792
Epoch: 029/100 | Batch 100/600 | Cost: 0.1255
Epoch: 029/100 | Batch 150/600 | Cost: 0.0690
Epoch: 029/100 | Batch 200/600 | Cost: 0.2150
Epoch: 029/100 | Batch 250/600 | Cost: 0.0909
Epoch: 029/100 | Batch 300/600 | Cost: 0.0711
Epoch: 029/100 | Batch 350/600 | Cost: 0.0627
Epoch: 029/100 | Batch 400/600 | Cost: 0.1496
Epoch: 029/100 | Batch 450/600 | Cost: 0.0469
Epoch: 029/100 | Batch 500/600 | Cost: 0.1110
Epoch: 029/100 | Batch 550/600 | Cost: 0.0649
Epoch: 029/100 Train Cost: 0.1276
Time elapsed: 7.41 min
Epoch: 030/100 | Batch 000/600 | Cost: 0.0995
Epoch: 030/100 | Batch 050/600 | Cost: 0.1993
Epoch: 030/100 | Batch 100/600 | Cost: 0.1390
Epoch: 030/100 | Batch 150/600 | Cost: 0.1341
Epoch: 030/100 | Batch 200/600 | Cost: 0.2182
Epoch: 030/100 | Batch 250/600 | Cost: 0.1023
Epoch: 030/100 | Batch 300/600 | Cost: 0.2283
Epoch: 030/100 | Batch 350/600 | Cost: 0.1221
Epoch: 030/100 | Batch 400/600 | Cost: 0.1379
Epoch: 030/100 | Batch 450/600 | Cost: 0.0997
Epoch: 030/100 | Batch 500/600 | Cost: 0.2087
Epoch: 030/100 | Batch 550/600 | Cost: 0.1617
Epoch: 030/100 Train Cost: 0.1239
Time elapsed: 7.69 min
Epoch: 031/100 | Batch 000/600 | Cost: 0.1583
Epoch: 031/100 | Batch 050/600 | Cost: 0.0807
Epoch: 031/100 | Batch 100/600 | Cost: 0.1403
Epoch: 031/100 | Batch 150/600 | Cost: 0.1334
Epoch: 031/100 | Batch 200/600 | Cost: 0.1108
Epoch: 031/100 | Batch 250/600 | Cost: 0.1222
Epoch: 031/100 | Batch 300/600 | Cost: 0.1343
Epoch: 031/100 | Batch 350/600 | Cost: 0.1721
Epoch: 031/100 | Batch 400/600 | Cost: 0.1117
Epoch: 031/100 | Batch 450/600 | Cost: 0.2101
Epoch: 031/100 | Batch 500/600 | Cost: 0.1273
Epoch: 031/100 | Batch 550/600 | Cost: 0.1186
Epoch: 031/100 Train Cost: 0.1213
Time elapsed: 7.97 min
Epoch: 032/100 | Batch 000/600 | Cost: 0.0605
Epoch: 032/100 | Batch 050/600 | Cost: 0.1341
Epoch: 032/100 | Batch 100/600 | Cost: 0.0510
Epoch: 032/100 | Batch 150/600 | Cost: 0.1197
Epoch: 032/100 | Batch 200/600 | Cost: 0.0694
Epoch: 032/100 | Batch 250/600 | Cost: 0.0718
Epoch: 032/100 | Batch 300/600 | Cost: 0.1687
Epoch: 032/100 | Batch 350/600 | Cost: 0.2078
Epoch: 032/100 | Batch 400/600 | Cost: 0.1164
Epoch: 032/100 | Batch 450/600 | Cost: 0.1178
Epoch: 032/100 | Batch 500/600 | Cost: 0.1386
Epoch: 032/100 | Batch 550/600 | Cost: 0.0762
Epoch: 032/100 Train Cost: 0.1186
Time elapsed: 8.24 min
Epoch: 033/100 | Batch 000/600 | Cost: 0.1162
Epoch: 033/100 | Batch 050/600 | Cost: 0.1687
Epoch: 033/100 | Batch 100/600 | Cost: 0.1318
Epoch: 033/100 | Batch 150/600 | Cost: 0.1335
Epoch: 033/100 | Batch 200/600 | Cost: 0.0748
Epoch: 033/100 | Batch 250/600 | Cost: 0.1592
Epoch: 033/100 | Batch 300/600 | Cost: 0.1242
Epoch: 033/100 | Batch 350/600 | Cost: 0.0672
Epoch: 033/100 | Batch 400/600 | Cost: 0.1689
Epoch: 033/100 | Batch 450/600 | Cost: 0.0577
Epoch: 033/100 | Batch 500/600 | Cost: 0.1485
Epoch: 033/100 | Batch 550/600 | Cost: 0.1135
Epoch: 033/100 Train Cost: 0.1160
Time elapsed: 8.53 min
Epoch: 034/100 | Batch 000/600 | Cost: 0.1288
Epoch: 034/100 | Batch 050/600 | Cost: 0.1259
Epoch: 034/100 | Batch 100/600 | Cost: 0.1408
Epoch: 034/100 | Batch 150/600 | Cost: 0.0513
Epoch: 034/100 | Batch 200/600 | Cost: 0.1225
Epoch: 034/100 | Batch 250/600 | Cost: 0.1701
Epoch: 034/100 | Batch 300/600 | Cost: 0.0998
Epoch: 034/100 | Batch 350/600 | Cost: 0.1754
Epoch: 034/100 | Batch 400/600 | Cost: 0.1232
Epoch: 034/100 | Batch 450/600 | Cost: 0.0854
Epoch: 034/100 | Batch 500/600 | Cost: 0.2354
Epoch: 034/100 | Batch 550/600 | Cost: 0.1089
Epoch: 034/100 Train Cost: 0.1136
Time elapsed: 8.81 min
Epoch: 035/100 | Batch 000/600 | Cost: 0.1284
Epoch: 035/100 | Batch 050/600 | Cost: 0.0512
Epoch: 035/100 | Batch 100/600 | Cost: 0.0721
Epoch: 035/100 | Batch 150/600 | Cost: 0.1171
Epoch: 035/100 | Batch 200/600 | Cost: 0.1219
Epoch: 035/100 | Batch 250/600 | Cost: 0.1390
Epoch: 035/100 | Batch 300/600 | Cost: 0.0962
Epoch: 035/100 | Batch 350/600 | Cost: 0.1066
Epoch: 035/100 | Batch 400/600 | Cost: 0.0646
Epoch: 035/100 | Batch 450/600 | Cost: 0.0693
Epoch: 035/100 | Batch 500/600 | Cost: 0.1041
Epoch: 035/100 | Batch 550/600 | Cost: 0.0721
Epoch: 035/100 Train Cost: 0.1112
Time elapsed: 9.09 min
Epoch: 036/100 | Batch 000/600 | Cost: 0.1870
Epoch: 036/100 | Batch 050/600 | Cost: 0.0619
Epoch: 036/100 | Batch 100/600 | Cost: 0.1851
Epoch: 036/100 | Batch 150/600 | Cost: 0.0951
Epoch: 036/100 | Batch 200/600 | Cost: 0.0465
Epoch: 036/100 | Batch 250/600 | Cost: 0.0991
Epoch: 036/100 | Batch 300/600 | Cost: 0.0823
Epoch: 036/100 | Batch 350/600 | Cost: 0.1259
Epoch: 036/100 | Batch 400/600 | Cost: 0.1150
Epoch: 036/100 | Batch 450/600 | Cost: 0.0740
Epoch: 036/100 | Batch 500/600 | Cost: 0.0479
Epoch: 036/100 | Batch 550/600 | Cost: 0.1561
Epoch: 036/100 Train Cost: 0.1098
Time elapsed: 9.35 min
Epoch: 037/100 | Batch 000/600 | Cost: 0.0758
Epoch: 037/100 | Batch 050/600 | Cost: 0.0773
Epoch: 037/100 | Batch 100/600 | Cost: 0.1108
Epoch: 037/100 | Batch 150/600 | Cost: 0.1162
Epoch: 037/100 | Batch 200/600 | Cost: 0.1215
Epoch: 037/100 | Batch 250/600 | Cost: 0.2244
Epoch: 037/100 | Batch 300/600 | Cost: 0.2486
Epoch: 037/100 | Batch 350/600 | Cost: 0.0707
Epoch: 037/100 | Batch 400/600 | Cost: 0.0366
Epoch: 037/100 | Batch 450/600 | Cost: 0.0986
Epoch: 037/100 | Batch 500/600 | Cost: 0.0479
Epoch: 037/100 | Batch 550/600 | Cost: 0.0614
Epoch: 037/100 Train Cost: 0.1067
Time elapsed: 9.63 min
Epoch: 038/100 | Batch 000/600 | Cost: 0.0596
Epoch: 038/100 | Batch 050/600 | Cost: 0.0828
Epoch: 038/100 | Batch 100/600 | Cost: 0.1886
Epoch: 038/100 | Batch 150/600 | Cost: 0.0589
Epoch: 038/100 | Batch 200/600 | Cost: 0.1077
Epoch: 038/100 | Batch 250/600 | Cost: 0.0876
Epoch: 038/100 | Batch 300/600 | Cost: 0.0783
Epoch: 038/100 | Batch 350/600 | Cost: 0.0621
Epoch: 038/100 | Batch 400/600 | Cost: 0.1678
Epoch: 038/100 | Batch 450/600 | Cost: 0.1629
Epoch: 038/100 | Batch 500/600 | Cost: 0.0761
Epoch: 038/100 | Batch 550/600 | Cost: 0.1326
Epoch: 038/100 Train Cost: 0.1050
Time elapsed: 9.91 min
Epoch: 039/100 | Batch 000/600 | Cost: 0.1822
Epoch: 039/100 | Batch 050/600 | Cost: 0.0721
Epoch: 039/100 | Batch 100/600 | Cost: 0.1229
Epoch: 039/100 | Batch 150/600 | Cost: 0.1629
Epoch: 039/100 | Batch 200/600 | Cost: 0.1607
Epoch: 039/100 | Batch 250/600 | Cost: 0.2023
Epoch: 039/100 | Batch 300/600 | Cost: 0.0886
Epoch: 039/100 | Batch 350/600 | Cost: 0.1024
Epoch: 039/100 | Batch 400/600 | Cost: 0.1186
Epoch: 039/100 | Batch 450/600 | Cost: 0.0599
Epoch: 039/100 | Batch 500/600 | Cost: 0.0927
Epoch: 039/100 | Batch 550/600 | Cost: 0.1248
Epoch: 039/100 Train Cost: 0.1025
Time elapsed: 10.19 min
Epoch: 040/100 | Batch 000/600 | Cost: 0.0858
Epoch: 040/100 | Batch 050/600 | Cost: 0.0347
Epoch: 040/100 | Batch 100/600 | Cost: 0.1175
Epoch: 040/100 | Batch 150/600 | Cost: 0.2041
Epoch: 040/100 | Batch 200/600 | Cost: 0.0303
Epoch: 040/100 | Batch 250/600 | Cost: 0.0481
Epoch: 040/100 | Batch 300/600 | Cost: 0.1258
Epoch: 040/100 | Batch 350/600 | Cost: 0.1230
Epoch: 040/100 | Batch 400/600 | Cost: 0.1449
Epoch: 040/100 | Batch 450/600 | Cost: 0.1702
Epoch: 040/100 | Batch 500/600 | Cost: 0.1170
Epoch: 040/100 | Batch 550/600 | Cost: 0.0472
Epoch: 040/100 Train Cost: 0.1005
Time elapsed: 10.48 min
Epoch: 041/100 | Batch 000/600 | Cost: 0.0456
Epoch: 041/100 | Batch 050/600 | Cost: 0.2133
Epoch: 041/100 | Batch 100/600 | Cost: 0.1101
Epoch: 041/100 | Batch 150/600 | Cost: 0.1815
Epoch: 041/100 | Batch 200/600 | Cost: 0.0578
Epoch: 041/100 | Batch 250/600 | Cost: 0.0818
Epoch: 041/100 | Batch 300/600 | Cost: 0.1105
Epoch: 041/100 | Batch 350/600 | Cost: 0.1001
Epoch: 041/100 | Batch 400/600 | Cost: 0.0740
Epoch: 041/100 | Batch 450/600 | Cost: 0.0965
Epoch: 041/100 | Batch 500/600 | Cost: 0.0920
Epoch: 041/100 | Batch 550/600 | Cost: 0.0447
Epoch: 041/100 Train Cost: 0.0987
Time elapsed: 10.75 min
Epoch: 042/100 | Batch 000/600 | Cost: 0.1327
Epoch: 042/100 | Batch 050/600 | Cost: 0.1168
Epoch: 042/100 | Batch 100/600 | Cost: 0.1099
Epoch: 042/100 | Batch 150/600 | Cost: 0.0678
Epoch: 042/100 | Batch 200/600 | Cost: 0.0865
Epoch: 042/100 | Batch 250/600 | Cost: 0.0882
Epoch: 042/100 | Batch 300/600 | Cost: 0.0895
Epoch: 042/100 | Batch 350/600 | Cost: 0.0368
Epoch: 042/100 | Batch 400/600 | Cost: 0.1905
Epoch: 042/100 | Batch 450/600 | Cost: 0.0773
Epoch: 042/100 | Batch 500/600 | Cost: 0.0934
Epoch: 042/100 | Batch 550/600 | Cost: 0.0818
Epoch: 042/100 Train Cost: 0.0968
Time elapsed: 11.03 min
Epoch: 043/100 | Batch 000/600 | Cost: 0.0484
Epoch: 043/100 | Batch 050/600 | Cost: 0.0810
Epoch: 043/100 | Batch 100/600 | Cost: 0.0729
Epoch: 043/100 | Batch 150/600 | Cost: 0.0331
Epoch: 043/100 | Batch 200/600 | Cost: 0.0718
Epoch: 043/100 | Batch 250/600 | Cost: 0.1023
Epoch: 043/100 | Batch 300/600 | Cost: 0.1212
Epoch: 043/100 | Batch 350/600 | Cost: 0.1359
Epoch: 043/100 | Batch 400/600 | Cost: 0.1224
Epoch: 043/100 | Batch 450/600 | Cost: 0.1202
Epoch: 043/100 | Batch 500/600 | Cost: 0.0533
Epoch: 043/100 | Batch 550/600 | Cost: 0.0882
Epoch: 043/100 Train Cost: 0.0949
Time elapsed: 11.30 min
Epoch: 044/100 | Batch 000/600 | Cost: 0.2524
Epoch: 044/100 | Batch 050/600 | Cost: 0.0895
Epoch: 044/100 | Batch 100/600 | Cost: 0.1663
Epoch: 044/100 | Batch 150/600 | Cost: 0.0978
Epoch: 044/100 | Batch 200/600 | Cost: 0.1342
Epoch: 044/100 | Batch 250/600 | Cost: 0.1485
Epoch: 044/100 | Batch 300/600 | Cost: 0.1373
Epoch: 044/100 | Batch 350/600 | Cost: 0.0375
Epoch: 044/100 | Batch 400/600 | Cost: 0.1527
Epoch: 044/100 | Batch 450/600 | Cost: 0.0635
Epoch: 044/100 | Batch 500/600 | Cost: 0.1155
Epoch: 044/100 | Batch 550/600 | Cost: 0.0742
Epoch: 044/100 Train Cost: 0.0937
Time elapsed: 11.58 min
Epoch: 045/100 | Batch 000/600 | Cost: 0.1664
Epoch: 045/100 | Batch 050/600 | Cost: 0.1629
Epoch: 045/100 | Batch 100/600 | Cost: 0.1524
Epoch: 045/100 | Batch 150/600 | Cost: 0.0401
Epoch: 045/100 | Batch 200/600 | Cost: 0.0967
Epoch: 045/100 | Batch 250/600 | Cost: 0.1322
Epoch: 045/100 | Batch 300/600 | Cost: 0.0590
Epoch: 045/100 | Batch 350/600 | Cost: 0.0608
Epoch: 045/100 | Batch 400/600 | Cost: 0.0720
Epoch: 045/100 | Batch 450/600 | Cost: 0.1067
Epoch: 045/100 | Batch 500/600 | Cost: 0.0794
Epoch: 045/100 | Batch 550/600 | Cost: 0.1118
Epoch: 045/100 Train Cost: 0.0916
Time elapsed: 11.83 min
Epoch: 046/100 | Batch 000/600 | Cost: 0.1120
Epoch: 046/100 | Batch 050/600 | Cost: 0.1013
Epoch: 046/100 | Batch 100/600 | Cost: 0.0787
Epoch: 046/100 | Batch 150/600 | Cost: 0.1088
Epoch: 046/100 | Batch 200/600 | Cost: 0.1725
Epoch: 046/100 | Batch 250/600 | Cost: 0.0488
Epoch: 046/100 | Batch 300/600 | Cost: 0.0979
Epoch: 046/100 | Batch 350/600 | Cost: 0.0574
Epoch: 046/100 | Batch 400/600 | Cost: 0.0469
Epoch: 046/100 | Batch 450/600 | Cost: 0.1673
Epoch: 046/100 | Batch 500/600 | Cost: 0.0737
Epoch: 046/100 | Batch 550/600 | Cost: 0.1828
Epoch: 046/100 Train Cost: 0.0902
Time elapsed: 12.02 min
Epoch: 047/100 | Batch 000/600 | Cost: 0.0709
Epoch: 047/100 | Batch 050/600 | Cost: 0.0443
Epoch: 047/100 | Batch 100/600 | Cost: 0.1874
Epoch: 047/100 | Batch 150/600 | Cost: 0.1338
Epoch: 047/100 | Batch 200/600 | Cost: 0.0819
Epoch: 047/100 | Batch 250/600 | Cost: 0.1726
Epoch: 047/100 | Batch 300/600 | Cost: 0.0988
Epoch: 047/100 | Batch 350/600 | Cost: 0.0556
Epoch: 047/100 | Batch 400/600 | Cost: 0.1415
Epoch: 047/100 | Batch 450/600 | Cost: 0.0810
Epoch: 047/100 | Batch 500/600 | Cost: 0.1385
Epoch: 047/100 | Batch 550/600 | Cost: 0.0712
Epoch: 047/100 Train Cost: 0.0888
Time elapsed: 12.20 min
Epoch: 048/100 | Batch 000/600 | Cost: 0.0474
Epoch: 048/100 | Batch 050/600 | Cost: 0.1193
Epoch: 048/100 | Batch 100/600 | Cost: 0.1212
Epoch: 048/100 | Batch 150/600 | Cost: 0.1456
Epoch: 048/100 | Batch 200/600 | Cost: 0.0319
Epoch: 048/100 | Batch 250/600 | Cost: 0.0624
Epoch: 048/100 | Batch 300/600 | Cost: 0.1839
Epoch: 048/100 | Batch 350/600 | Cost: 0.0441
Epoch: 048/100 | Batch 400/600 | Cost: 0.1124
Epoch: 048/100 | Batch 450/600 | Cost: 0.1508
Epoch: 048/100 | Batch 500/600 | Cost: 0.0229
Epoch: 048/100 | Batch 550/600 | Cost: 0.0451
Epoch: 048/100 Train Cost: 0.0870
Time elapsed: 12.39 min
Epoch: 049/100 | Batch 000/600 | Cost: 0.0533
Epoch: 049/100 | Batch 050/600 | Cost: 0.0815
Epoch: 049/100 | Batch 100/600 | Cost: 0.0685
Epoch: 049/100 | Batch 150/600 | Cost: 0.0931
Epoch: 049/100 | Batch 200/600 | Cost: 0.0687
Epoch: 049/100 | Batch 250/600 | Cost: 0.1772
Epoch: 049/100 | Batch 300/600 | Cost: 0.1153
Epoch: 049/100 | Batch 350/600 | Cost: 0.0655
Epoch: 049/100 | Batch 400/600 | Cost: 0.0904
Epoch: 049/100 | Batch 450/600 | Cost: 0.0870
Epoch: 049/100 | Batch 500/600 | Cost: 0.0349
Epoch: 049/100 | Batch 550/600 | Cost: 0.1194
Epoch: 049/100 Train Cost: 0.0856
Time elapsed: 12.57 min
Epoch: 050/100 | Batch 000/600 | Cost: 0.0501
Epoch: 050/100 | Batch 050/600 | Cost: 0.0583
Epoch: 050/100 | Batch 100/600 | Cost: 0.0328
Epoch: 050/100 | Batch 150/600 | Cost: 0.0740
Epoch: 050/100 | Batch 200/600 | Cost: 0.0518
Epoch: 050/100 | Batch 250/600 | Cost: 0.1065
Epoch: 050/100 | Batch 300/600 | Cost: 0.1028
Epoch: 050/100 | Batch 350/600 | Cost: 0.0720
Epoch: 050/100 | Batch 400/600 | Cost: 0.1389
Epoch: 050/100 | Batch 450/600 | Cost: 0.0661
Epoch: 050/100 | Batch 500/600 | Cost: 0.0897
Epoch: 050/100 | Batch 550/600 | Cost: 0.0802
Epoch: 050/100 Train Cost: 0.0854
Time elapsed: 12.76 min
Epoch: 051/100 | Batch 000/600 | Cost: 0.2093
Epoch: 051/100 | Batch 050/600 | Cost: 0.0506
Epoch: 051/100 | Batch 100/600 | Cost: 0.1178
Epoch: 051/100 | Batch 150/600 | Cost: 0.0597
Epoch: 051/100 | Batch 200/600 | Cost: 0.0624
Epoch: 051/100 | Batch 250/600 | Cost: 0.0750
Epoch: 051/100 | Batch 300/600 | Cost: 0.1243
Epoch: 051/100 | Batch 350/600 | Cost: 0.1244
Epoch: 051/100 | Batch 400/600 | Cost: 0.1236
Epoch: 051/100 | Batch 450/600 | Cost: 0.0861
Epoch: 051/100 | Batch 500/600 | Cost: 0.1096
Epoch: 051/100 | Batch 550/600 | Cost: 0.0776
Epoch: 051/100 Train Cost: 0.0826
Time elapsed: 12.94 min
Epoch: 052/100 | Batch 000/600 | Cost: 0.1166
Epoch: 052/100 | Batch 050/600 | Cost: 0.1127
Epoch: 052/100 | Batch 100/600 | Cost: 0.0742
Epoch: 052/100 | Batch 150/600 | Cost: 0.0592
Epoch: 052/100 | Batch 200/600 | Cost: 0.0922
Epoch: 052/100 | Batch 250/600 | Cost: 0.0834
Epoch: 052/100 | Batch 300/600 | Cost: 0.0435
Epoch: 052/100 | Batch 350/600 | Cost: 0.0611
Epoch: 052/100 | Batch 400/600 | Cost: 0.0500
Epoch: 052/100 | Batch 450/600 | Cost: 0.1059
Epoch: 052/100 | Batch 500/600 | Cost: 0.0338
Epoch: 052/100 | Batch 550/600 | Cost: 0.0356
Epoch: 052/100 Train Cost: 0.0816
Time elapsed: 13.12 min
Epoch: 053/100 | Batch 000/600 | Cost: 0.0643
Epoch: 053/100 | Batch 050/600 | Cost: 0.0581
Epoch: 053/100 | Batch 100/600 | Cost: 0.0435
Epoch: 053/100 | Batch 150/600 | Cost: 0.0338
Epoch: 053/100 | Batch 200/600 | Cost: 0.0861
Epoch: 053/100 | Batch 250/600 | Cost: 0.0908
Epoch: 053/100 | Batch 300/600 | Cost: 0.0509
Epoch: 053/100 | Batch 350/600 | Cost: 0.0967
Epoch: 053/100 | Batch 400/600 | Cost: 0.1341
Epoch: 053/100 | Batch 450/600 | Cost: 0.0613
Epoch: 053/100 | Batch 500/600 | Cost: 0.0772
Epoch: 053/100 | Batch 550/600 | Cost: 0.1246
Epoch: 053/100 Train Cost: 0.0803
Time elapsed: 13.31 min
Epoch: 054/100 | Batch 000/600 | Cost: 0.0922
Epoch: 054/100 | Batch 050/600 | Cost: 0.0407
Epoch: 054/100 | Batch 100/600 | Cost: 0.0612
Epoch: 054/100 | Batch 150/600 | Cost: 0.1718
Epoch: 054/100 | Batch 200/600 | Cost: 0.0491
Epoch: 054/100 | Batch 250/600 | Cost: 0.0591
Epoch: 054/100 | Batch 300/600 | Cost: 0.0485
Epoch: 054/100 | Batch 350/600 | Cost: 0.0909
Epoch: 054/100 | Batch 400/600 | Cost: 0.0342
Epoch: 054/100 | Batch 450/600 | Cost: 0.0866
Epoch: 054/100 | Batch 500/600 | Cost: 0.0931
Epoch: 054/100 | Batch 550/600 | Cost: 0.0534
Epoch: 054/100 Train Cost: 0.0796
Time elapsed: 13.50 min
Epoch: 055/100 | Batch 000/600 | Cost: 0.1031
Epoch: 055/100 | Batch 050/600 | Cost: 0.0534
Epoch: 055/100 | Batch 100/600 | Cost: 0.0534
Epoch: 055/100 | Batch 150/600 | Cost: 0.1212
Epoch: 055/100 | Batch 200/600 | Cost: 0.1284
Epoch: 055/100 | Batch 250/600 | Cost: 0.0635
Epoch: 055/100 | Batch 300/600 | Cost: 0.0691
Epoch: 055/100 | Batch 350/600 | Cost: 0.1205
Epoch: 055/100 | Batch 400/600 | Cost: 0.1592
Epoch: 055/100 | Batch 450/600 | Cost: 0.1360
Epoch: 055/100 | Batch 500/600 | Cost: 0.0465
Epoch: 055/100 | Batch 550/600 | Cost: 0.0805
Epoch: 055/100 Train Cost: 0.0776
Time elapsed: 13.68 min
Epoch: 056/100 | Batch 000/600 | Cost: 0.0946
Epoch: 056/100 | Batch 050/600 | Cost: 0.1189
Epoch: 056/100 | Batch 100/600 | Cost: 0.0669
Epoch: 056/100 | Batch 150/600 | Cost: 0.1079
Epoch: 056/100 | Batch 200/600 | Cost: 0.0639
Epoch: 056/100 | Batch 250/600 | Cost: 0.0982
Epoch: 056/100 | Batch 300/600 | Cost: 0.1121
Epoch: 056/100 | Batch 350/600 | Cost: 0.0475
Epoch: 056/100 | Batch 400/600 | Cost: 0.0320
Epoch: 056/100 | Batch 450/600 | Cost: 0.0477
Epoch: 056/100 | Batch 500/600 | Cost: 0.0731
Epoch: 056/100 | Batch 550/600 | Cost: 0.0978
Epoch: 056/100 Train Cost: 0.0765
Time elapsed: 13.87 min
Epoch: 057/100 | Batch 000/600 | Cost: 0.0354
Epoch: 057/100 | Batch 050/600 | Cost: 0.0847
Epoch: 057/100 | Batch 100/600 | Cost: 0.0734
Epoch: 057/100 | Batch 150/600 | Cost: 0.0732
Epoch: 057/100 | Batch 200/600 | Cost: 0.1427
Epoch: 057/100 | Batch 250/600 | Cost: 0.0273
Epoch: 057/100 | Batch 300/600 | Cost: 0.1002
Epoch: 057/100 | Batch 350/600 | Cost: 0.0815
Epoch: 057/100 | Batch 400/600 | Cost: 0.0608
Epoch: 057/100 | Batch 450/600 | Cost: 0.0754
Epoch: 057/100 | Batch 500/600 | Cost: 0.0453
Epoch: 057/100 | Batch 550/600 | Cost: 0.0916
Epoch: 057/100 Train Cost: 0.0751
Time elapsed: 14.05 min
Epoch: 058/100 | Batch 000/600 | Cost: 0.1022
Epoch: 058/100 | Batch 050/600 | Cost: 0.0907
Epoch: 058/100 | Batch 100/600 | Cost: 0.0390
Epoch: 058/100 | Batch 150/600 | Cost: 0.0463
Epoch: 058/100 | Batch 200/600 | Cost: 0.0690
Epoch: 058/100 | Batch 250/600 | Cost: 0.0475
Epoch: 058/100 | Batch 300/600 | Cost: 0.0482
Epoch: 058/100 | Batch 350/600 | Cost: 0.0754
Epoch: 058/100 | Batch 400/600 | Cost: 0.0698
Epoch: 058/100 | Batch 450/600 | Cost: 0.0572
Epoch: 058/100 | Batch 500/600 | Cost: 0.0877
Epoch: 058/100 | Batch 550/600 | Cost: 0.1232
Epoch: 058/100 Train Cost: 0.0747
Time elapsed: 14.24 min
Epoch: 059/100 | Batch 000/600 | Cost: 0.0695
Epoch: 059/100 | Batch 050/600 | Cost: 0.0705
Epoch: 059/100 | Batch 100/600 | Cost: 0.0316
Epoch: 059/100 | Batch 150/600 | Cost: 0.1175
Epoch: 059/100 | Batch 200/600 | Cost: 0.0241
Epoch: 059/100 | Batch 250/600 | Cost: 0.0599
Epoch: 059/100 | Batch 300/600 | Cost: 0.1111
Epoch: 059/100 | Batch 350/600 | Cost: 0.0401
Epoch: 059/100 | Batch 400/600 | Cost: 0.0768
Epoch: 059/100 | Batch 450/600 | Cost: 0.0607
Epoch: 059/100 | Batch 500/600 | Cost: 0.0665
Epoch: 059/100 | Batch 550/600 | Cost: 0.0495
Epoch: 059/100 Train Cost: 0.0732
Time elapsed: 14.42 min
Epoch: 060/100 | Batch 000/600 | Cost: 0.0427
Epoch: 060/100 | Batch 050/600 | Cost: 0.0375
Epoch: 060/100 | Batch 100/600 | Cost: 0.0363
Epoch: 060/100 | Batch 150/600 | Cost: 0.0894
Epoch: 060/100 | Batch 200/600 | Cost: 0.1137
Epoch: 060/100 | Batch 250/600 | Cost: 0.1091
Epoch: 060/100 | Batch 300/600 | Cost: 0.0676
Epoch: 060/100 | Batch 350/600 | Cost: 0.0459
Epoch: 060/100 | Batch 400/600 | Cost: 0.2015
Epoch: 060/100 | Batch 450/600 | Cost: 0.0297
Epoch: 060/100 | Batch 500/600 | Cost: 0.0414
Epoch: 060/100 | Batch 550/600 | Cost: 0.0992
Epoch: 060/100 Train Cost: 0.0720
Time elapsed: 14.61 min
Epoch: 061/100 | Batch 000/600 | Cost: 0.1128
Epoch: 061/100 | Batch 050/600 | Cost: 0.0415
Epoch: 061/100 | Batch 100/600 | Cost: 0.0939
Epoch: 061/100 | Batch 150/600 | Cost: 0.0601
Epoch: 061/100 | Batch 200/600 | Cost: 0.0369
Epoch: 061/100 | Batch 250/600 | Cost: 0.0849
Epoch: 061/100 | Batch 300/600 | Cost: 0.0731
Epoch: 061/100 | Batch 350/600 | Cost: 0.0260
Epoch: 061/100 | Batch 400/600 | Cost: 0.0802
Epoch: 061/100 | Batch 450/600 | Cost: 0.0339
Epoch: 061/100 | Batch 500/600 | Cost: 0.1191
Epoch: 061/100 | Batch 550/600 | Cost: 0.1475
Epoch: 061/100 Train Cost: 0.0711
Time elapsed: 14.79 min
Epoch: 062/100 | Batch 000/600 | Cost: 0.0638
Epoch: 062/100 | Batch 050/600 | Cost: 0.0907
Epoch: 062/100 | Batch 100/600 | Cost: 0.0354
Epoch: 062/100 | Batch 150/600 | Cost: 0.0537
Epoch: 062/100 | Batch 200/600 | Cost: 0.0811
Epoch: 062/100 | Batch 250/600 | Cost: 0.0775
Epoch: 062/100 | Batch 300/600 | Cost: 0.0646
Epoch: 062/100 | Batch 350/600 | Cost: 0.0561
Epoch: 062/100 | Batch 400/600 | Cost: 0.0666
Epoch: 062/100 | Batch 450/600 | Cost: 0.1187
Epoch: 062/100 | Batch 500/600 | Cost: 0.0685
Epoch: 062/100 | Batch 550/600 | Cost: 0.1266
Epoch: 062/100 Train Cost: 0.0698
Time elapsed: 14.98 min
Epoch: 063/100 | Batch 000/600 | Cost: 0.0389
Epoch: 063/100 | Batch 050/600 | Cost: 0.1210
Epoch: 063/100 | Batch 100/600 | Cost: 0.0786
Epoch: 063/100 | Batch 150/600 | Cost: 0.0751
Epoch: 063/100 | Batch 200/600 | Cost: 0.0267
Epoch: 063/100 | Batch 250/600 | Cost: 0.0620
Epoch: 063/100 | Batch 300/600 | Cost: 0.0535
Epoch: 063/100 | Batch 350/600 | Cost: 0.0713
Epoch: 063/100 | Batch 400/600 | Cost: 0.0522
Epoch: 063/100 | Batch 450/600 | Cost: 0.1066
Epoch: 063/100 | Batch 500/600 | Cost: 0.1077
Epoch: 063/100 | Batch 550/600 | Cost: 0.0242
Epoch: 063/100 Train Cost: 0.0691
Time elapsed: 15.18 min
Epoch: 064/100 | Batch 000/600 | Cost: 0.0208
Epoch: 064/100 | Batch 050/600 | Cost: 0.0608
Epoch: 064/100 | Batch 100/600 | Cost: 0.0468
Epoch: 064/100 | Batch 150/600 | Cost: 0.0503
Epoch: 064/100 | Batch 200/600 | Cost: 0.0561
Epoch: 064/100 | Batch 250/600 | Cost: 0.0982
Epoch: 064/100 | Batch 300/600 | Cost: 0.0424
Epoch: 064/100 | Batch 350/600 | Cost: 0.0973
Epoch: 064/100 | Batch 400/600 | Cost: 0.0672
Epoch: 064/100 | Batch 450/600 | Cost: 0.0593
Epoch: 064/100 | Batch 500/600 | Cost: 0.0551
Epoch: 064/100 | Batch 550/600 | Cost: 0.0851
Epoch: 064/100 Train Cost: 0.0679
Time elapsed: 15.37 min
Epoch: 065/100 | Batch 000/600 | Cost: 0.0424
Epoch: 065/100 | Batch 050/600 | Cost: 0.0535
Epoch: 065/100 | Batch 100/600 | Cost: 0.1614
Epoch: 065/100 | Batch 150/600 | Cost: 0.0471
Epoch: 065/100 | Batch 200/600 | Cost: 0.0542
Epoch: 065/100 | Batch 250/600 | Cost: 0.0706
Epoch: 065/100 | Batch 300/600 | Cost: 0.0543
Epoch: 065/100 | Batch 350/600 | Cost: 0.0789
Epoch: 065/100 | Batch 400/600 | Cost: 0.0617
In [ ]:
plt.plot(range(len(minibatch_cost)), minibatch_cost)
plt.ylabel(‘Cross Entropy’)
plt.xlabel(‘Minibatch’)
plt.show()
plt.plot(range(len(epoch_cost)), epoch_cost)
plt.ylabel(‘Cross Entropy’)
plt.xlabel(‘Epoch’)
plt.show()
In [ ]:
def compute_accuracy(net, data_loader):
correct_pred, num_examples = 0, 0
with torch.no_grad():
for features, targets in data_loader:
features = features.view(-1, 28*28).to(DEVICE)
targets = targets.to(DEVICE)
a1, a2 = net.forward(features)
predicted_labels = torch.argmax(a2, 1)
num_examples += targets.size(0)
correct_pred += (predicted_labels == targets).sum()
return correct_pred.float()/num_examples * 100
print(‘Training Accuracy: %.2f’ % compute_accuracy(model, train_loader))
print(‘Test Accuracy: %.2f’ % compute_accuracy(model, test_loader))