Simple neural network implementation using Chainer-Model description-

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

  1. Data preparation

  2. Model description

  3. Optimization algorithm settings

  4. Learning

  5. Result output Of

  6. Model description

I will write about.

Neural network to build

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.

Irisのネットワーク_1.png

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. Irisニューラルネットワーク_2.png

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.

Irisニューラルネットワーク_3.png

Iris model

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.

reference

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

Simple neural network implementation using Chainer-Model description-
Simple neural network implementation using Chainer
Simple neural network implementation using Chainer-Data preparation-
Simple neural network implementation using Chainer-optimization algorithm setting-
Simple neural network theory and implementation
Implementation of "blurred" neural network using Chainer
Neural network implementation in python
Implementation of a convolutional neural network using only Numpy
Neural network implementation (NumPy only)
Rank learning using neural network (Implementation of RankNet by Chainer)
Implementation of a two-layer neural network 2
PRML Chapter 5 Neural Network Python Implementation
Simple classification model with neural network
Try using TensorFlow-Part 2-Convolutional Neural Network (MNIST)
Reinforcement learning 10 Try using a trained neural network.
Another style conversion method using Convolutional Neural Network
Parametric Neural Network
Author estimation using neural network and Doc2Vec (Aozora Bunko)
Model using convolutional neural network in natural language processing
Bayesian optimization implementation of neural network hyperparameters (Chainer + GPyOpt)
Implement Convolutional Neural Network
Implement Neural Network from 1
Convolutional neural network experience
Try building a neural network in Python without using a library