How to train a parameter outside the model?

*爱你&永不变心* 提交于 2020-04-30 07:18:47

问题


I am implementing the following architecture in Tensorflow 2.0 Dual Encoder LSTM

C and R are sentences encoded into a fixed dimension by the two LSTM's. Then they are passed through a function sigmoid(CMR). We can assume that R and C are both 256 dimensional matrices and M is a 256 * 256 matrix. The matrix M is learned during training. Since I want to train M, I declared M = tf.Variable(shape,trainable = True). But after fitting the model, the values of M are still not changing. How to tell tensorflow to compute the gradients for M automatically ? Below is my code. Code

来源:https://stackoverflow.com/questions/61434540/how-to-train-a-parameter-outside-the-model

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!