tensorflow动态扩展占位符列表

时间:2016-08-03 22:32:51

标签: python tensorflow placeholder lstm

我想在图的每次迭代中动态扩展占位符列表。在创建图形时,我必须定义在for循环中使用的variable_length,然后我可以相应地将数据提供给占位符。我尝试使用tf.while_loop,我可以扩展占位符列表,但是在此tf.while_loop之前完成了馈送过程并发生错误:

Error: "list index is out of range" 

代码:

   self._train_data = []
    for _ in range( variable_length ):
        placeholder_input = tf.placeholder(tf.float32, shape=[self._batch_size, self._input_size])    
        self._train_data.append(placeholder_input)

执行和喂食完成如下

feed_dict = dict()
for i in range(self._num_unrollings + 1):
   feed_dict[self._train_data[i]] = batches[i]

_, loss_reduced = self._session.run([ self._optimizer, self._loss_reduced], feed_dict=feed_dict)

0 个答案:

没有答案