22.02.2024 Views

Daniel Voigt Godoy - Deep Learning with PyTorch Step-by-Step A Beginner’s Guide-leanpub

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Figure 11.13 - Continuous bag-of-words

cbow_features = dummy_cbow.embedding(batch_context).mean(dim=1)

cbow_features

Output

tensor([[ 0.7606, -0.2743, 0.3298]], grad_fn=<MeanBackward1>)

The bag-of-words has three dimensions, which are the features used to compute

the logits for our multiclass classification problem.

Figure 11.14 - Logits

logits = dummy_cbow.linear(cbow_features)

logits

Output

tensor([[ 0.3542, 0.6937, -0.2028, -0.5873, 0.2099]],

grad_fn=<AddmmBackward>)

Word Embeddings | 923

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!