I am trying to understand the implementation of Theano LSTM (at the moment, the link does not work for any reason, but I hope that it will return soon).
In the code, I see the following part:
emb = tparams['Wemb'][x.flatten()].reshape([n_timesteps, n_samples, options['dim_proj']])
To make it "context independent", I rewrite it as follows:
e = W[x.flatten()]].reshape([n1, n2, n3])
where the dimension x is (n1, n2) and the dimension W is (N, n3) .
So my assumption is that the code can be rewritten to be shorter. In particular, we can simply write:
e = W[x]
Or, if we use the original notation, it should be:
emb = tparams['Wemb'][x]
I'm right?
To provide a little more context, x is a 2D array containing integers representing words (for example, 27 means "word number 27"). W in my notation (or tparams['Wemb'] ) in the original notation is a 2D matrix in which each row corresponds to a word. Thus, it is a word embedding matrix (Word2Vec) that maps each word into a real vector.
Roman source share