언어 모델링을위한 기본 lstm 코드를 실행하고 있습니다. 하지만 난하고 싶지 않아. BPTT
. 나는 state
이 LSTMStateTuple
이다, 그러나 tf.stop_gradient(state)
tensorflow에서 LSTMStateTuple의 그래디언트를 중지하는 방법
with tf.variable_scope("RNN"):
for time_step in range(N):
if time_step > 0: tf.get_variable_scope().reuse_variables()
(cell_output, state) = cell(inputs[:, time_step, :], state)
같은 것을하고 싶은, 그래서 시도 :
for lli in range(len(state)):
print(state[lli].c, state[lli].h)
state[lli].c = tf.stop_gradient(state[lli].c)
state[lli].h = tf.stop_gradient(state[lli].h)
그러나 나는 AttributeError: can't set attribute
오류가있어 : 나는 또한 사용하려고
File "/home/liyu-iri/IRRNNL/word-rnn/ptb/models/decoupling.py", line 182, in __init__
state[lli].c = tf.stop_gradient(state[lli].c)
AttributeError: can't set attribute
을 tf.assign
이지만 state[lli].c
은 변수가 아닙니다.
그래, 어떻게 그라데이션을 멈출 수 있습니까? LSTMStateTuple
? 아니면 BPTT를 중단 할 수 있습니까? 나는 단 하나 액자에서 BP를하고 싶다.
고맙습니다.
대단히 감사합니다! 그게 많은 도움이됩니다! –