ニューラルネットワークと層

PyTorchで学ぶIntroduction to Deep Learning

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

ニューラルネットワークの層

入力・中間・出力を持つニューラルネットワーク図

PyTorchで学ぶIntroduction to Deep Learning

ニューラルネットワークの層

入力・中間・出力を持つニューラルネットワーク図

PyTorchで学ぶIntroduction to Deep Learning

ニューラルネットワークの層

入力・中間・出力を持つニューラルネットワーク図

PyTorchで学ぶIntroduction to Deep Learning

ニューラルネットワークの層

入力・中間・出力を持つニューラルネットワーク図

PyTorchで学ぶIntroduction to Deep Learning

最初のニューラルネットワーク

入力と出力のみの基本的なニューラルネットワーク図

  • 全結合ネットワーク
  • 線形モデルと同等
PyTorchで学ぶIntroduction to Deep Learning

ニューラルネットワークを設計する

ニューラルネットワークへの入力を表す3つのノード

# Importing as nn to avoid writing torch.nn
import torch.nn as nn


# Create input_tensor with three features input_tensor = torch.tensor( [[0.3471, 0.4547, -0.2356]])
  • 入力ニューロン = 特徴量
  • 出力ニューロン = クラス
PyTorchで学ぶIntroduction to Deep Learning

ニューラルネットワークを設計する

線形層を示す矢印付きで入力を表す3つのノード

# Importing as nn to avoid writing torch.nn
import torch.nn as nn


# Create input_tensor with three features input_tensor = torch.tensor( [[0.3471, 0.4547, -0.2356]])
# Define our linear layer linear_layer = nn.Linear(
in_features=3,
out_features=2
)
PyTorchで学ぶIntroduction to Deep Learning

ニューラルネットワークを設計する

入力と出力のみの基本的なニューラルネットワーク図

# Importing as nn to avoid writing torch.nn
import torch.nn as nn


# Create input_tensor with three features input_tensor = torch.tensor( [[0.3471, 0.4547, -0.2356]])
# Define our linear layer linear_layer = nn.Linear( in_features=3, out_features=2 )
# Pass input through linear layer output = linear_layer(input_tensor) print(output)
PyTorchで学ぶIntroduction to Deep Learning

ニューラルネットワークを設計する

入力と出力のみの基本的なニューラルネットワーク図

$$ $$ $$

# Pass input through linear layer
output = linear_layer(input_tensor)
print(output)
tensor([[-0.2415, -0.1604]], 
    grad_fn=<AddmmBackward0>)
PyTorchで学ぶIntroduction to Deep Learning

重みとバイアス

output = linear_layer(input_tensor)

線形演算の図示

PyTorchで学ぶIntroduction to Deep Learning

重みとバイアス

  • .weight
    print(linear_layer.weight)
    
Parameter containing:
tensor([[-0.4799,  0.4996,  0.1123],
        [-0.0365, -0.1855,  0.0432]], 
        requires_grad=True)

$$

  • 各特徴量の重要度を表す
  • .bias
    print(linear_layer.bias)
    
Parameter containing:
tensor([0.0310, 0.1537], requires_grad=True)

$$

$$

  • ニューロンの基準出力を与える
PyTorchで学ぶIntroduction to Deep Learning

全結合ネットワークの動作

入力と出力のみの基本的なニューラルネットワーク図

PyTorchで学ぶIntroduction to Deep Learning

全結合ネットワークの動作

入力と出力のみの基本的なニューラルネットワーク図

PyTorchで学ぶIntroduction to Deep Learning

全結合ネットワークの動作

入力と出力のみの基本的なニューラルネットワーク図

  • 湿度の特徴量はより大きな重みを持つ
  • バイアスは基準情報を考慮するため
PyTorchで学ぶIntroduction to Deep Learning

Passons à la pratique !

PyTorchで学ぶIntroduction to Deep Learning

Preparing Video For Download...