I'm experimenting the code in https://github.com/dennybritz/cnn-text-classification-tf and initiallize the word embeddings with Glove. Now I would like to freeze most of the word embeddings and only train a small part. The only relevant thread I can find is Update only part of the word embedding matrix in Tensorflow
However, I still have trouble understanding how to do it properly in my case. Given something like this:
optimizer = tf.train.AdamOptimizer(1e-3)
grads_and_vars = optimizer.compute_gradients(cnn.loss)
train_op = optimizer.apply_gradients(grads_and_vars)
How do I change the indices to only train part of the embeddings in this case?
Thanks!