0
I tried to do this myself using the code below, but my Pytorch bidirectional RNN outputting all NaN? Can someone please advise or provide code for inputting a Gensim word vector to Pytorch RNN and outputting next word prediction. Code uses Python 3.6 and Pytorch most recent version of February 2019.
import gensim
import gensim.downloader as api
import torch
import torch, torch.nn as nn
from torch.autograd import Variable

word_vectors = api.load("glove-wiki-gigaword-100")

before_blank = ['hi', 'how', 'are']
before_blank_vectors = []
for word in before_blank:
    before_blank_vectors.append(word_vectors.get_vector(word))

seq_len = 3
batch_size = 1
embedding_size = 100
hidden_size = 1
output_size = 1

before_blank_vectors_tensor = Variable(torch.FloatTensor(3, 1, 100))

bi_rnn = torch.nn.RNN(input_size=100, hidden_size=1, num_layers=1, batch_first=False, bidirectional=True)

bi_output, bi_hidden = bi_rnn(before_blank_vectors_tensor)

print(bi_output)

Prints out:
tensor([[[nan, nan]],

        [[nan, nan]],

        [[nan, nan]]], grad_fn=<CatBackward>)