首页 文章

更新到TensorFlow 0.11后图形结构的变化

提问于
浏览
0

今天,我从TensorFlow 0.10更新到TensorFlow 0.11 . 为了检查更新是否成功,我决定运行一个我知道工作正常的MNIST教程 .

该程序使用TensorFlow 0.11正确运行,但我注意到计算图形的方式发生了重大变化 . 这就是before更新的方式,这就是它出现的方式now . 在后一张图片中,我添加了一个红色矩形,以便将注意力集中在其他节点上 .

Does anyone know why this change occurs, and how I can make the graph look reasonable again?

也许以下代码片段会有所帮助 . 它对应于图形中改变外观的部分 .

# Cost function 
cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits=y_unscal,
                                                    labels=y_plh)
cost = tf.reduce_mean(cross_entropy)

# Training op
optimiser = tf.train.AdamOptimizer(learning_rate=1e-4).minimize(cost)

非常感谢提前!

1 回答

  • 0

    将该操作放在 variable_scope 中 .

    with tf.variable_scope('loss_ops'):
        # Cost function 
        cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits=y_unscal,labels=y_plh)
        cost = tf.reduce_mean(cross_entropy)
    
        # Training op
        optimiser = tf.train.AdamOptimizer(learning_rate=1e-4).minimize(cost)
    

    这样,名为 loss_ops 的块将出现在图形可视化中

相关问题