我已经将RNNCell
子类化为我的RNN的构建块。我将这个对象的一个实例放入tf.dynamic_rnn
,然后在我的Agent
类中定义一个预测函数:
class Agent():
def __init__(self):
...
def predictions(self):
cell = RNNCell()
output, last_state = tf.dynamic_rnn(cell, inputs = ...)
return output
一切正常,但我现在如何添加图层的直方图?我试过在RNNCell
中这样做,但不起作用:
class RNNCell(tf.nn.rnn_cell.RNNCell):
def __init__(self):
super(RNNCell, self).__init__()
self._output_size = 15
self._state_size = 15
self._histogram1 = None
def __call__(self, X, state):
network = tflearn.layers.conv_2d(X, 5, [1, 3], activation='relu', weights_init=tflearn.initializations.variance_scaling(), padding="valid")
self._histogram1 = tf.summary.histogram("layer1_hist_summary", network)
...
@property
def histogram1(self):
return self._histogram1
然后呢
class Agent():
def __init__(self):
...
def predictions(self):
cell = RNNCell()
self.histogram1 = cell.histogram1
output, last_state = tf.dynamic_rnn(cell, inputs = ...)
return output
稍后当我运行sess.run(agent.histogram1, feed_dict=...)
时,我得到错误TypeError: Fetch argument None has invalid type <class 'NoneType'>
我认为问题在于代理的价值自身组织图1从未更新以反映RNNCell中分配的摘要。你知道吗
Agent predictions()方法的代码在此处将代理的historogram1值初始化为None:
当调用RNNCell的
__call__()
方法时,它会更新historogram1的RNNCell值但探员的historogram1副本显然没有更新,所以打电话时:
你知道吗组织学试剂1仍然没有。你知道吗
我在发布的代码中看不到训练前合并摘要的地方,因此缺少的步骤可能在未发布的代码中的某个地方。你知道吗
相关问题 更多 >
编程相关推荐