Neuronové sítě a vrstvy

Introduction to Deep Learning with PyTorch

Jasmin Ludolf

Senior Data Science Content Developer, DataCamp

Vrstvy neuronové sítě

Diagram neuronové sítě se vstupem, skrytou vrstvou a výstupem

Introduction to Deep Learning with PyTorch

Vrstvy neuronové sítě

Diagram neuronové sítě se vstupem, skrytou vrstvou a výstupem

Introduction to Deep Learning with PyTorch

Vrstvy neuronové sítě

Diagram neuronové sítě se vstupem, skrytou vrstvou a výstupem

Introduction to Deep Learning with PyTorch

Vrstvy neuronové sítě

Diagram neuronové sítě se vstupem, skrytou vrstvou a výstupem

Introduction to Deep Learning with PyTorch

Naše první neuronová síť

Diagram základní neuronové sítě pouze se vstupem a výstupem

  • Plně propojená síť
  • Ekvivalent lineárního modelu
Introduction to Deep Learning with PyTorch

Návrh neuronové sítě

Tři uzly představující vstup neuronové sítě

# 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]])
  • Vstupní neurony = příznaky
  • Výstupní neurony = třídy
Introduction to Deep Learning with PyTorch

Návrh neuronové sítě

Tři uzly představující vstup neuronové sítě se šipkami dopředu znázorňující lineární vrstvu

# 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
)
Introduction to Deep Learning with PyTorch

Návrh neuronové sítě

Diagram základní neuronové sítě pouze se vstupem a výstupem

# 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)
Introduction to Deep Learning with PyTorch

Návrh neuronové sítě

Diagram základní neuronové sítě pouze se vstupem a výstupem

$$ $$ $$

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

Váhy a biasy

output = linear_layer(input_tensor)

Znázornění lineární operace

Introduction to Deep Learning with PyTorch

Váhy a biasy

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

$$

  • Odráží důležitost jednotlivých příznaků
  • .bias
    print(linear_layer.bias)
    
Parameter containing:
tensor([0.0310, 0.1537], requires_grad=True)

$$

$$

  • Poskytuje neuronu výchozí výstup
Introduction to Deep Learning with PyTorch

Plně propojená síť v praxi

Diagram základní neuronové sítě pouze se vstupem a výstupem

Introduction to Deep Learning with PyTorch

Plně propojená síť v praxi

Diagram základní neuronové sítě pouze se vstupem a výstupem

Introduction to Deep Learning with PyTorch

Plně propojená síť v praxi

Diagram základní neuronové sítě pouze se vstupem a výstupem

  • Příznak vlhkosti bude mít vyšší váhu
  • Bias zachycuje výchozí informaci
Introduction to Deep Learning with PyTorch

Lass uns üben!

Introduction to Deep Learning with PyTorch

Preparing Video For Download...