Regularization for LSTM in tensorflow

前端 未结 3 1782
庸人自扰
庸人自扰 2021-02-05 15:10

Tensorflow offers a nice LSTM wrapper.

rnn_cell.BasicLSTM(num_units, forget_bias=1.0, input_size=None,
           state_is_tuple=False, activation=tanh)
<         


        
3条回答
  •  忘掉有多难
    2021-02-05 15:26

    tf.trainable_variables gives you a list of Variable objects that you can use to add the L2 regularization term. Note that this add regularization for all variables in your model. If you want to restrict the L2 term only to a subset of the weights, you can use the name_scope to name your variables with specific prefixes, and later use that to filter the variables from the list returned by tf.trainable_variables.

提交回复
热议问题