How to convert a vector back to natural language using pre-trained glove model?

280 views Asked by At

I am training my neural network with a large corpus of text data. First I converted every text(words) into vector using glove. Those vectors are the input to the neural network. Now, I have an output vector from the output layer of the network. How do I convert that output vector back to natural language?

code to map word to vector:

def load_glove(dimen):
  mapping = {}
  with open(("./data/glove/glove.6B/glove.6B." + str(dimen) + "d.txt")) as f:
      for line in f:    
          li = line.split()
          mapping[li[0]] = map(float, li[1:])    
    return mapping

One possibility may be to use cosine similarity. We have one vector and need to find the similarity in vector space with cosine angle. Can tensorflow help me here?

0

There are 0 answers