embedding-lookup

Tensorflow embedding lookup with unequal sized lists

亡梦爱人 提交于 2020-01-01 11:25:47
问题 Hej guys, I'm trying to project multi labeled categorical data into a dense space using embeddings. Here's an toy example. Let's say I have four categories and want to project them into a 2D space. Furthermore I got two instances, the first one belonging to category 0 and the second one to category 1. The code will look something like this: sess = tf.InteractiveSession() embeddings = tf.Variable(tf.random_uniform([4, 2], -1.0, 1.0)) sess.run(tf.global_variables_initializer()) y = tf.nn

how do I use a very large (>2M) word embedding in tensorflow?

痴心易碎 提交于 2019-12-20 19:57:10
问题 I am running a model with a very big word embedding (>2M words). When I use tf.embedding_lookup, it expects the matrix, which is big. When I run, I subsequently get out of GPU memory error. If I reduce the size of the embedding, everything works fine. Is there a way to deal with larger embedding? 回答1: The recommended way is to use a partitioner to shard this large tensor across several parts: embedding = tf.get_variable("embedding", [1000000000, 20], partitioner=tf.fixed_size_partitioner(3))

Tensorflow embedding lookup with unequal sized lists

蓝咒 提交于 2019-12-04 07:47:45
Hej guys, I'm trying to project multi labeled categorical data into a dense space using embeddings. Here's an toy example. Let's say I have four categories and want to project them into a 2D space. Furthermore I got two instances, the first one belonging to category 0 and the second one to category 1. The code will look something like this: sess = tf.InteractiveSession() embeddings = tf.Variable(tf.random_uniform([4, 2], -1.0, 1.0)) sess.run(tf.global_variables_initializer()) y = tf.nn.embedding_lookup(embeddings, [0,1]) y.eval() and return something like this: array([[ 0.93999457, -0.83051205