【发布时间】:2016-08-23 10:57:12
【问题描述】:
对我来说,Tensorflow 的一个谜团是:变量何时代表单个张量与批次?下面是一个具有连续值输出的网络示例(不是分类器)。在以loss 开头的行中,我通过从真值中减去预测值并将批次中这些差异的绝对值相加来计算损失。在该行中,Tensorflow 为truthValues_placeholder 插入了一批真值,因此truthValues_placeholder 是一个“批处理”张量,即批处理中的每个项目都有一个条目。但是,上一行将prediction 计算为单个值(而不是批处理)。我的问题:Tensorflow 神奇地将prediction 更改为“批处理张量”,因此我是否正确地为批处理中的每个项目计算了一个条目?
graph = tf.Graph()
with tf.Graph().as_default():
...
# Network layers here
...
# Final layer
prediction = tf.matmul(inputsToLastLayer, weightsOutputLayer) + biasesOutputLayer
loss = tf.nn.l2_loss(tf.sub(prediction, truthValues_placeholder))
...
global_step = tf.Variable(0, name='global_step', trainable=False)
train_op = optimizer.minimize(loss, global_step=global_step)
...
sess = tf.Session()
init = tf.initialize_all_variables()
sess.run(init)
for step in xrange(maxSteps):
feed_dict = fill_feed_dict(..., truthValues_placeholder,...)
【问题讨论】:
标签: tensorflow