Tersorflow CIFAR-10 训练示例报错及解决方案

2023-12-22 11:48

本文主要是介绍Tersorflow CIFAR-10 训练示例报错及解决方案,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

在我运行cifar10示例的过程中,遇到了许多问题,调试了几天才搞定,本文对基于python的深度学习的初学者有些帮助。

Tersorflow  CIFAR-10 训练示例报错及解决方案

1.AttributeError: 'module' object has noattribute 'random_crop'

解决方案:

将distorted_image= tf.image.random_crop(reshaped_image, [height, width])改为:

distorted_image = tf.random_crop(reshaped_image,[height, width,3])

 

2.  AttributeError: 'module'object has no attribute 'SummaryWriter'

解决方案:

tf.train.SummaryWriter改为:tf.summary.FileWriter

 

3.  AttributeError: 'module'object has no attribute 'summaries'

解决方案:

 tf.merge_all_summaries()改为:summary_op =tf.summaries.merge_all()

 


4. AttributeError: 'module' object hasno attribute 'histogram_summary'

tf.histogram_summary(var.op.name,var)改为:  tf.summaries.histogram()

 


5. AttributeError: 'module' object hasno attribute 'scalar_summary'

tf.scalar_summary(l.op.name+ ' (raw)', l)

解决方案:

tf.scalar_summary('images',images)改为:tf.summary.scalar('images', images)

tf.image_summary('images',images)改为:tf.summary.image('images', images)

 

6. ValueError: Only call `softmax_cross_entropy_with_logits` withnamed arguments (labels=..., logits=..., ...)

解决方案:

   cifar10.loss(labels, logits) 改为:cifar10.loss(logits=logits,labels=labels)

 cross_entropy= tf.nn.softmax_cross_entropy_with_logits(
        logits, dense_labels,name='cross_entropy_per_example')

改为:

  cross_entropy = tf.nn.softmax_cross_entropy_with_logits(
        logits=logits, labels=dense_labels,name='cross_entropy_per_example')

 

7. TypeError: Using a `tf.Tensor` as a Python `bool` isnot allowed. Use `if t is not None:` instead of `if t:` to test if a tensor isdefined, and use TensorFlow ops such as tf.cond to execute subgraphsconditioned on the value of a tensor.

解决方案:

if grad: 改为  if grad is not None:

 

8. ValueError: Shapes (2, 128, 1) and () are incompatible

解决方案:

concated = tf.concat(1, [indices, sparse_labels])改为:

concated= tf.concat([indices, sparse_labels], 1)

 

9. 报错:

File"/home/lily/work/Tensorflow/CIRFAR-10/tensorflow.cifar10-master/cifar10_input.py",line 83, in read_cifar10

    result.key, value =http://blog.csdn.net/xiao_lxl/article/details/reader.read(filename_queue)

  File"/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/io_ops.py",line 326, in read

queue_ref = queue.queue_ref

AttributeError: 'str' object hasno attribute 'queue_ref'

解决方案:

由于训练样本的路径需要修改,给cifar10_input.py中data_dir赋值为本地数据所在的文件夹

这篇关于Tersorflow CIFAR-10 训练示例报错及解决方案的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/523832

相关文章

详解SpringBoot+Ehcache使用示例

《详解SpringBoot+Ehcache使用示例》本文介绍了SpringBoot中配置Ehcache、自定义get/set方式,并实际使用缓存的过程,文中通过示例代码介绍的非常详细,对大家的学习或者... 目录摘要概念内存与磁盘持久化存储:配置灵活性:编码示例引入依赖:配置ehcache.XML文件:配置

Java高效实现PowerPoint转PDF的示例详解

《Java高效实现PowerPoint转PDF的示例详解》在日常开发或办公场景中,经常需要将PowerPoint演示文稿(PPT/PPTX)转换为PDF,本文将介绍从基础转换到高级设置的多种用法,大家... 目录为什么要将 PowerPoint 转换为 PDF安装 Spire.Presentation fo

idea突然报错Malformed \uxxxx encoding问题及解决

《idea突然报错Malformeduxxxxencoding问题及解决》Maven项目在切换Git分支时报错,提示project元素为描述符根元素,解决方法:删除Maven仓库中的resolv... 目www.chinasem.cn录问题解决方式总结问题idea 上的 maven China编程项目突然报错,是

Python中isinstance()函数原理解释及详细用法示例

《Python中isinstance()函数原理解释及详细用法示例》isinstance()是Python内置的一个非常有用的函数,用于检查一个对象是否属于指定的类型或类型元组中的某一个类型,它是Py... 目录python中isinstance()函数原理解释及详细用法指南一、isinstance()函数

python中的高阶函数示例详解

《python中的高阶函数示例详解》在Python中,高阶函数是指接受函数作为参数或返回函数作为结果的函数,下面:本文主要介绍python中高阶函数的相关资料,文中通过代码介绍的非常详细,需要的朋... 目录1.定义2.map函数3.filter函数4.reduce函数5.sorted函数6.自定义高阶函数

Vue实现路由守卫的示例代码

《Vue实现路由守卫的示例代码》Vue路由守卫是控制页面导航的钩子函数,主要用于鉴权、数据预加载等场景,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着... 目录一、概念二、类型三、实战一、概念路由守卫(Navigation Guards)本质上就是 在路

JAVA实现Token自动续期机制的示例代码

《JAVA实现Token自动续期机制的示例代码》本文主要介绍了JAVA实现Token自动续期机制的示例代码,通过动态调整会话生命周期平衡安全性与用户体验,解决固定有效期Token带来的风险与不便,感兴... 目录1. 固定有效期Token的内在局限性2. 自动续期机制:兼顾安全与体验的解决方案3. 总结PS

C#中通过Response.Headers设置自定义参数的代码示例

《C#中通过Response.Headers设置自定义参数的代码示例》:本文主要介绍C#中通过Response.Headers设置自定义响应头的方法,涵盖基础添加、安全校验、生产实践及调试技巧,强... 目录一、基础设置方法1. 直接添加自定义头2. 批量设置模式二、高级配置技巧1. 安全校验机制2. 类型

Python屏幕抓取和录制的详细代码示例

《Python屏幕抓取和录制的详细代码示例》随着现代计算机性能的提高和网络速度的加快,越来越多的用户需要对他们的屏幕进行录制,:本文主要介绍Python屏幕抓取和录制的相关资料,需要的朋友可以参考... 目录一、常用 python 屏幕抓取库二、pyautogui 截屏示例三、mss 高性能截图四、Pill

Java中的Schema校验技术与实践示例详解

《Java中的Schema校验技术与实践示例详解》本主题详细介绍了在Java环境下进行XMLSchema和JSONSchema校验的方法,包括使用JAXP、JAXB以及专门的JSON校验库等技术,本文... 目录1. XML和jsON的Schema校验概念1.1 XML和JSON校验的必要性1.2 Sche