-
Book Overview & Buying
-
Table Of Contents
Deep Learning from the Basics
By :
In this section, we will implement the apple example we've described in Python using the multiplication node in a computational graph as the multiplication layer (MulLayer) and the addition node as the addition layer (AddLayer).
In the next section, we will implement the "layers" that constitute a neural network in one class. The "layer" here is a functional unit in a neural network—the Sigmoid layer for a sigmoid function, and the Affine layer for matrix multiplication. Therefore, we will also implement multiplication and addition nodes here on a "layer" basis.
We will implement a layer so that it has two common methods (interfaces): forward() and backward(), which correspond to forward propagation and backward propagation, respectively. Now, you can implement a multiplication layer as a class called MulLayer, as follows (the source code is located at ch05/layer_naive...