# (input)--> [Linear->Sigmoid] -> [Linear->Sigmoid] -->(output)
# handle 10,000 vectors at a time
Z1 = nnet.LinearLayer(input_shape=(rows * cols, nnet_batch), n_out=80)
-A1 = nnet.SigmoidLayer(Z1.Z.shape)
-ZO = nnet.LinearLayer(input_shape=A1.A.shape, n_out=10)
-AO = nnet.SigmoidLayer(ZO.Z.shape)
+A1 = nnet.SigmoidLayer(Z1.shape)
+ZO = nnet.LinearLayer(input_shape=A1.shape, n_out=10)
+AO = nnet.SigmoidLayer(ZO.shape)
net = (Z1, A1, ZO, AO)
res = nnet.forward(net, test_images[:, 0:10000])
train_y = nnet.label_vectors(train_labels, 10)
for i in range(100):
for batch in range(0, num_train, nnet_batch):
- cost = nnet.train(net, train_images[:, batch:(batch + nnet_batch)], train_y[:, batch:(batch + nnet_batch)], learning_rate=1)
+ cost = nnet.train(net, train_images[:, batch:(batch + nnet_batch)], train_y[:, batch:(batch + nnet_batch)], learning_rate=(100-i)/100)
print(f'cost after training round {i}: {cost}')
print(f'correctly recognized images after training: {nnet.accuracy(net, test_images, test_labels)}%')