Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

多層パーセプトロン

多層パーセプトロン(multilayer perceptron: MLP)、あるいはFeedForward Neural Network

z=h(Wx+b)zl=h(∑j=1wjlxj+bl)z = h(W x + b)\\ z_l = h( \sum_{j=1} w_{jl} x_j + b_l)

第ll層のii番目のユニットの出力は

zi(l)=h(∑j=1N(l−1)wij(l)zj(l−1)+bi(l))z_i^{(l)} = h \left( \sum^{N^{(l-1)}}_{j=1} w^{(l)}_{ij} z_j^{(l-1)} + b_i^{(l)} \right)

Pytorchで試す

めちゃくちゃ単純な二値分類問題

Using cpu device
NeuralNetwork(
  (flatten): Flatten(start_dim=1, end_dim=-1)
  (linear_relu_stack): Sequential(
    (0): Linear(in_features=2, out_features=10, bias=True)
    (1): ReLU()
    (2): Linear(in_features=10, out_features=10, bias=True)
    (3): ReLU()
    (4): Linear(in_features=10, out_features=2, bias=True)
  )
)
Shape of X [N, C, H, W]: torch.Size([1, 2])
Shape of y: torch.Size([1]) torch.int64
<Figure size 640x480 with 1 Axes>
loss: 1.285138  [    1/10000]
loss: 0.016027  [ 1001/10000]
loss: 0.093124  [ 2001/10000]
loss: 0.030537  [ 3001/10000]
loss: 0.000748  [ 4001/10000]
loss: 0.028218  [ 5001/10000]
loss: 0.044488  [ 6001/10000]
loss: 0.006413  [ 7001/10000]
loss: 0.007662  [ 8001/10000]
loss: 0.000128  [ 9001/10000]
Test Error: 
 Accuracy: 99.6%, Avg loss: 0.017850