What is embedding layer in PyTorch?

Updated May 17, 2026

Short answer

Embedding layers convert indices into dense vectors.

Deep explanation

They map discrete tokens into continuous vector space for NLP tasks.

Real-world example

Used in NLP models like transformers.

Common mistakes

  • Passing one-hot vectors instead of indices.

Follow-up questions

  • Why embeddings instead of one-hot?
  • What is embedding dimension?

More PyTorch interview questions

View all →