in Education by
What does the following function do? Should I consider it as a lookup table like in skip-gram model? tf.nn.embedding_lookup(params, ids, partition_strategy='mod', name=None) Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
It is similar to the tf.gather which returns elements of params as per the indexes specifies by ids. Ex- para = tf.constant([10,20,80,40]) id = tf.constant([1,2,3]) print tf.nn.embedding_lookup(param,id).eval() This will give the output: [20,80,40] But,The main function of embedding_lookup is to retrieve rows of the params tensor.This params agrument mya have a list of tensors instead of a single tensor. Ex- param1 = tf.constant([10,2]) param2 = tf.constant([20,30]) ids = tf.constant([2,0,2,1,2,3]) result = tf.nn.embedding_lookup([param1, param2], ids) In this cases, the indexes as specified in ids corresponds to the element of tensors as per the partition strategy. The partition_startegy controls the way how the ids will get distributed among the list, the default partition strategy is ‘mod’. The mod strategy: Index 0 correspond to the first element of first tensor while index 1 corresponds to the first element of second tensor and so on.For index n,it cannot correspond to the n+1 tensor since the list params contain only n tensor so the nth index will correspond to the second element of first tensor. Similarly, the index n+1 corresponds to the second element of the second tensor and so on. Now coming back to the code, param1 = tf.constant([10,2]) param2 = tf.constant([20,30]) ids = tf.constant([2,0,2,1,2,3]) result = tf.nn.embedding_lookup([param1, param2], ids) Result: [2 10 2 20 2 30] Hope this helps!

Related questions

0 votes
    I was looking at the docs of TensorFlow about tf.nn.conv2d here. But I can't understand what it does or ... it raised the question. Select the correct answer from above options...
asked Jan 27, 2022 in Education by JackTerrance
0 votes
    In tf.nn.max_pool of tensorflow what is the difference between 'SAME' and 'VALID'? I read in here that ... pool means in tensorflow? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I am searching for the better option to save a trained model in PyTorch, these are the options I am using ... the above two functions? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I want to assign a value to a TensorFlow variable in Python and I am using this: import tensorflow as tf import ... do to correct this? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I want different learning layers in different layers just like we do in Caffe. I just want to speed up the training ... can I do this? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I am looking for an open source neural network library. So far, I have looked at FANN, WEKA, and OpenNN. Are the ... , and ease of use. Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    What is global_step ? why do we use '0' while setting up global_step? def training(loss,learning_rate): tf. ... global_step becomes 1? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    In the MNIST beginner tutorial, there is the statement accuracy = tf.reduce_mean(tf.cast(correct_prediction, "float")) tf ... (x,1)? Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I am trying to understand the role of the Flatten function in Keras. Below is my code, which is a simple two ... flatten it? Thanks! Select the correct answer from above options...
asked Feb 8, 2022 in Education by JackTerrance
0 votes
    I'm wondering how to calculate precision and recall measures for multiclass multilabel classification, i.e. classification ... labels? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    What is the role of Flatten in Keras. I am executing the code below and it's a two layered network. The ... output is already flat? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
0 votes
    I am having problem in understanding the difference between three optimizers for loss.I went through some documents ... differences? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I want my model to be trained with some classified images. They are of different sizes, so how can I train ... resizing the images? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I read that regularization terms are implemented by manually adding an additional term to loss value in neural network ... it manually? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    Is tf.contrib.layers.flatten(x) the same as tf.reshape(x, [n, 1])? Can anyone help me with this? Select the correct answer from above options...
asked Jan 25, 2022 in Education by JackTerrance
...