使用 tf打印文檔我寫 print_op = tf.print("tensors:", cut_points[0,0,:], output_stream=sys.stderr) with tf.control_dependencies([print_op]): return cut_points但無論如何都不會(huì)輸出到 std (我看到其他日志,會(huì)話確實(shí)評估了這一點(diǎn)。
1 回答

當(dāng)年話下
TA貢獻(xiàn)1890條經(jīng)驗(yàn) 獲得超9個(gè)贊
tf.control_dependencies僅影響在上下文中創(chuàng)建的新操作。在您的代碼段中,您沒有在上下文中創(chuàng)建任何新操作,因此它沒有任何效果。最簡單的解決方案是使用tf.identity將產(chǎn)生相同結(jié)果但具有控制依賴關(guān)系的操作:
print_op = tf.print("tensors:", cut_points[0,0,:], output_stream=sys.stderr)
with tf.control_dependencies([print_op]):
return tf.identity(cut_points)
添加回答
舉報(bào)
0/150
提交
取消