Thank you @CedricLy for your response. If I make the optimizer not update the doc_tf layer when I create the optimizer, then it will never learn the embeddings. Is there a way to tell the optimizer from the forward function of DeepClusterEmbedder not to update doc_tf before I calculate all the embeddings and only update it after that? Currently, I am achieving it by calling doc_tf.eval() and doc_tf.train() before and after the embedding calculation respectively. Is that the correct way?