Update a subset of weights in TensorFlow

后端 未结 2 1316
予麋鹿
予麋鹿 2020-12-16 06:21

Does anyone know how to update a subset (i.e. only some indices) of the weights that are used in the forward propagation?

My guess is that I might be able to do that

2条回答
  •  我在风中等你
    2020-12-16 07:18

    Easiest way is to pull the tf.Variable into python (as a numpy array) using npvar = sess.run(tfvar), then perform some operation on it such as npvar[1, 2] = -10. Then you can upload the modified data back into tensorflow using sess.run(tfvar.assign(npvar)).

    Obviously this is very slow and not really useful for training but it does work.

提交回复
热议问题