IniziaInizia gratis

Linear layer network

Neural networks often contain many layers, but most of them are linear layers. Understanding a single linear layer helps you grasp how they work before adding complexity.

Apply a linear layer to an input tensor and observe the output.

Questo esercizio fa parte del corso

Introduction to Deep Learning with PyTorch

Visualizza il corso

Istruzioni dell'esercizio

  • Create a Linear layer that takes 3 features as input and returns 2 outputs.
  • Pass input_tensor through the linear layer.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

import torch
import torch.nn as nn

input_tensor = torch.tensor([[0.3471, 0.4547, -0.2356]])

# Create a Linear layer
linear_layer = nn.____(
                         in_features=____, 
                         out_features=____
                         )

# Pass input_tensor through the linear layer
output = ____(____)

print(output)
Modifica ed esegui il codice