April 2026
461 pages
17h 56m
English
To loosen things up, let’s write a method that outputs the matrixes in sequence, that is, from the input layer to the output layer. In Python, the print function handles the formatting for NumPy matrixes, so we don’t have to do much. The only setting we make causes three decimal places to be printed to obtain an output aligned in columns, as shown in Listing 5.4.
def print(self): print('Multilayer Perceptron - Network Architecture') # 7 digits in total, output with three decimal places np.set_printoptions( formatter={'float': lambda x: "{0:7.3f}".format(x)}) for nn_part in self.network: print(nn_part) print('----------v----------')
Listing 5.4 Output of the Network Architecture
You’ll see the result ...
Read now
Unlock full access