From Last time, I am writing an article to actually build a neural network using Chainer, which is a framework for deep learning. This time
Data preparation
Model description
Optimization algorithm settings
Learning
Result output Of
Model description
I will write about.
Last time As I wrote, the Iris data used this time is input. It is 4D and its output is 3D. If you think very simply, the network can be constructed as shown in the figure below.
However, what should be built is a neural network with an intermediate layer. A layer is required between the input and the output. Simplify the case and add one middle layer. The number of nodes is six.
Then, the network will be as shown in the figure below.
However, as I wrote in About Chainer's basic objects ~ links ~, the mapping from layer l to layer l + 1 is
y = wx + b
It is expressed by the linear. In other words, bias b is required for each of the input layer and the intermediate layer. The figure that takes this into consideration is as follows.
Now, let's express Iris' neural network model using a Chain object.
class IrisChain(Chain):
def __init__():
super(IrisChain, self).__init__(
l1 = L.Linear(4, 6),
l2 = L.Linear(6, 3),
)
def __call__(self, x, y):
return F.mean_squared_error(self.fwd(x), y)
def fwd(self, x):
h1 = F.sigmoid(self.l1(x))
h2 = self.l2(h1)
return h2
Please refer to the article here for a detailed explanation. Input layer: 4 Middle layer: 6 Output layer: 3 So 4 → 6
l1 = L.Linear(4, 6)
6 → 3
l2 = L.Linear(6, 4)
It is expressed as.
That's all for this time. Next time, I will write about optimization to find the minimum value of the error obtained by this model.
Takayoshi Yamashita Deep learning Kodansha that can be seen in the illustration Hiroyuki Shinno Practical deep learning with Chainer-How to implement complex NN-Ohmsha
Recommended Posts