February 2018
Intermediate to advanced
262 pages
6h 59m
English
The vectors variable returns a torch tensor of shape vocab_size x dimensions containing the pretrained embeddings. We have to store the embeddings to the weights of our embedding layer. We can assign the weights of the embeddings by accessing the weights of the embeddings layer as demonstrated by the following code.
model.embedding.weight.data = TEXT.vocab.vectors
model represents the object of our network, and embedding represents the embedding layer. As we are using the embedding layer with new dimensions, there will be a small change in the input to the linear layer that comes after the embedding layer. The following code has the new architecture, which is similar to the previously-used architecture ...
Read now
Unlock full access