Tensorflow 我可以在RNNCell的调用中存储状态吗
我想为一个非常简单的单元构建我自己的RNNCell,其中输出为[-1,0,1],但是在我的_调用中,我会根据前面时间步的输出进行计算 所以我的问题是,是否有可能在_调用_方法中保留状态以在调用之间重用Tensorflow 我可以在RNNCell的调用中存储状态吗,tensorflow,Tensorflow,我想为一个非常简单的单元构建我自己的RNNCell,其中输出为[-1,0,1],但是在我的_调用中,我会根据前面时间步的输出进行计算 所以我的问题是,是否有可能在_调用_方法中保留状态以在调用之间重用 class MyCell(RNNCell): # Size of my state # My state consists of 1 tensor with num_units columns @property def state_size(self):
class MyCell(RNNCell):
# Size of my state
# My state consists of 1 tensor with num_units columns
@property
def state_size(self):
return self._num_units
# I emit at every timestep
@property
def output_size(self):
return self._num_units
def __call__(self,input,state):
#Intermediate calculations for 1 time step
#Can i keep state here, for example info about last input
#or output?
return output, new_state
这对tf.dynamic\n不起作用,因此不鼓励使用。如果希望状态参数工作,请通过状态参数传递所有状态。它可能与普通tf.rnn一起工作,但不能保证