MulaiMulai sekarang secara 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.

Latihan ini adalah bagian dari kursus

Introduction to Deep Learning with PyTorch

Lihat Kursus

Petunjuk latihan

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

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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)
Edit dan Jalankan Kode