• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

pycharm中TensorFlow调试常见问题小结

python 搞代码 4年前 (2022-01-09) 31次浏览 已收录 0个评论
文章目录[隐藏]

1. RuntimeError: Attempted to use a closed Session.

在pycharm下调用tensorflow库时,运行出现以下问题:

RuntimeError: Atte

本文来源gao!%daima.com搞$代*!码网1

mpted to use a closed Session.

解决方法:将STEP=5000开始的程序整体右移,包含在“with”内

可能遇见的问题:python代码如何整体移动

  • 选中代码,按下“Tab”键即可整体右移
  • 选中代码,按下“Shift+Tab”键即可整体左移

2. AttributeError: module ‘tensorflow’ has no attribute ‘select’

调用tf.select出错

将tf.select替换为tf.where即可

3. UnicodeDecodeError: ‘utf-8′ codec can’t decode byte 0xff in position 0: invalid start byte

利用TensorFlow的tf.gfile.FastGFile读入图像发生上述错误:

4. python中用plt.imshow()显示图像之后,程序就停止运行,必须关掉显示的图像才继续运行

可以将show()写在进程里,通过调用进程来打开图片,那么进程的运行状态就不会影响到主程序的往下执行了

import threading 
import Image 
class ThreadClass(threading.Thread): 
def run(self): 
im=Image.open(‘z.jpg') 
im.show()

print (1) 
t = ThreadClass() 
t.start() 
print (2) 
a=input(‘End')

运行结果为:先打印出‘1’,然后显示图片z.jpg,接着再不关闭图片的情况下打印出‘2’。
具体应用的时候你根据需要组织代码。

5. AttributeError: module ‘tensorflow.python.ops.image_ops’ has no attribute ‘per_image_whitening’

TensorFlow对归一化函数tf.image.per_image_whitening(img_data)进行了修改,变为以下形式:

adjusted = tf.image.per_image_standardization(img_data)

6. ValueError: Tried to convert ‘min_object_covered’ to a tensor and failed. Error: None values not supported.

解决方法:

 begin, size, bbox_for_draw = tf.image.sample_distorted_bounding_box(
        tf.shape(img_data), bounding_boxes=boxes,min_object_covered=0.1)

7. NameError:name ‘xrange’ is not defined


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:pycharm中TensorFlow调试常见问题小结
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址