chainer.functions.embed_id

chainer.functions.embed_id(x, W, ignore_label=None)[source]

Efficient linear function for one-hot input.

This function implements so called word embedding. It takes two arguments: a set of IDs (words) x in \(B\) dimensional integer vector, and a set of all ID (word) embeddings W in \(V \times d\) float32 matrix. It outputs \(B \times d\) matrix whose i-th column is the x[i]-th column of W.

This function is only differentiable on the input W.

Parameters:
  • x (Variable) – Batch vectors of IDs.
  • W (Variable) – Representation of each ID (a.k.a. word embeddings).
  • ignore_label (int or None) – If ignore_label is an int value, i-th column of return value is filled with 0.
Returns:

Output variable.

Return type:

Variable

See also

EmbedID