Tensorflow LSTM Regularization

前端 未结 2 683
清歌不尽
清歌不尽 2021-01-25 17:02

I was wondering how one can implement l1 or l2 regularization within an LSTM in TensorFlow? TF doesn\'t give you access to the internal weights of the LSTM, so I\'m not certain

2条回答
  •  猫巷女王i
    2021-01-25 17:26

    The answers in the link you mentioned are the correct way to do it. Iterate through tf.trainable_variables and find the variables associated with your LSTM.

    An alternative, more complicated and possibly more brittle approach is to re-enter the LSTM's variable_scope, set reuse_variables=True, and call get_variable(). But really, the original solution is faster and less brittle.

提交回复
热议问题