0Pricing
Deep Learning Academy · Lekcja

nn.Embedding: uczone wektory słów

Poznać tablicę wyszukiwania trenowaną za pomocą spadku gradientowego

nn.Embedding: uczone wektory słów to bezpłatna lekcja Deep Learning Academy na CoddyKit. To lekcja 2 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Deep Learning Academy, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Deep Learning Academy zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

Ids Alone Are Not Enough

Token ids are just labels. The id 5 is not greater than 2 in any meaningful way, so feeding raw ids to a net misleads it.

One-Hot Is Wasteful

One way to represent ids is a giant one-hot vector, but with thousands of words it is huge, sparse, and carries no similarity.

Enter the Embedding

An embedding maps each id to a short dense vector of floats. These few numbers can encode rich meaning about the word.

It Is a Lookup Table

Think of nn.Embedding as a lookup table: row i holds the vector for token id i. Indexing the table fetches that row.

import torch.nn as nn
emb = nn.Embedding(num_embeddings=1000, embedding_dim=16)

Two Key Arguments

You set num_embeddings to your vocab size and embedding_dim to how many numbers each word vector holds.

Look Up a Word

Pass a tensor of ids and the layer returns their vectors. A batch of ids becomes a batch of dense vectors instantly.

ids = torch.tensor([1, 5, 2])
vecs = emb(ids)  # shape (3, 16)

Output Shape Grows a Dim

The embedding adds an extra dimension. An input of shape (batch, length) becomes (batch, length, embedding_dim).

The Vectors Start Random

At first the embedding rows are random. They hold no meaning yet, just noise waiting to be shaped by training.

They Are Trainable

Embedding weights are parameters. Gradient descent nudges each word vector during training, so the table learns over time.

Choosing the Dimension

A larger embedding_dim can capture more nuance but costs memory. Small tasks use 16 to 100; large language models use far more.

Plug It Into a Model

The embedding is usually the first layer. It converts ids to vectors, then later layers process those vectors as usual.

Quick Check

How does nn.Embedding turn a token id into a vector?

Recap

nn.Embedding is a trainable lookup table mapping ids to dense vectors. It starts random and learns meaning through training. ✅

Często zadawane pytania

Czy lekcja „nn.Embedding: uczone wektory słów” jest bezpłatna?

Tak — pełny tekst „nn.Embedding: uczone wektory słów” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Deep Learning Academy, przejdź na CoddyKit PRO. Kurs Deep Learning Academy zawiera 4 lekcji w sumie.

Co nauczysz się w „nn.Embedding: uczone wektory słów”?

Poznać tablicę wyszukiwania trenowaną za pomocą spadku gradientowego Ćwiczysz Deep Learning Academy z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Deep Learning Academy?

Nie wymagamy żadnego doświadczenia. Deep Learning Academy w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 2 z 4.

Ile czasu zajmuje lekcja „nn.Embedding: uczone wektory słów”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Deep Learning Academy?

Tak. Każda lekcja Deep Learning Academy zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Tokenizacja i budowanie słownika
  2. nn.Embedding: uczone wektory słów
  3. Dlaczego embeddingi przechwytują znaczenie
  4. Wytrenować klasyfikator tekstu
← Powrót do Deep Learning Academy