To learn the foundation very clearly, I coded MLP, from scratch and trained MNIST dataset. (it was a 3 vs 7 model, a binary classifier). For that I used a Linear function in each neuron, and Relu as activation. and for the final layer I used Sigmoid. I wanted to expand this model from just a binary classifier to multi-class classifier (where each instance belongs to one and only one class) I learned about Softmax activation that can be used in the final layer and then creating a loss function for MNIST model. The first step is to load the dataset into numpy array. def fetch(url): import requests, os, numpy, hashlib, gzip fp = os.path.join("/tmp", hashlib.md5(url.encode('utf-8')).hexdigest()) if os.path.isfile(fp): with open(fp, "rb") as f: dat = f.read() else: with open(fp, "wb") as f: dat = requests.get(url).content f.write(dat) return numpy.frombuffer(gzip.decompress(dat), dtype=numpy.uint8).copy() X_train = fetch("http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz")[0x10:].reshape((-1, 28, 28)) Y_train = fetch("http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz")[8:] X_test = fetch("http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz")[0x10:].reshape((-1, 28, 28)) Y_test = fetch("http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz")[8:] With this– X_train, Y_train and X_test, Y_test ready to train and validate. The next step is implementing Softmax for the final layer of MLP that I code, so ...