tensorflow踩坑

  • 安装
  1. pip install tensorflow
  2. 先安装 anaconda,然后 conda install tensorflow
    [ps: 推荐使用方法2,可以有效处理在不同服务器上动态链接库版本问题]
  • tf.Print() 的使用

由于 tensorflow 的所有计算都是在图构建完之后进行feed,因此没有办法在设计图的时候设置断点或者 print 出结果,这样不方便 debug。使用 tf.Print() 就可以解决这个问题:
target_tensor_print = tf.Print(target_tensor, [target_tensor], "提示信息")

tensorflow踩坑_第1张图片
tf.Print

这样就可以看到流经 target_tensor 的数据了。
或者可以查看 target_tensor 的形状:
tf.Print(target_tensor, [tf.shape(target_tensor)], "提示信息")

你可能感兴趣的:(tensorflow踩坑)