前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python3环境下 tensorflow环境中经常遇到'*' has type str, but expected one of: bytes问题的解决

python3环境下 tensorflow环境中经常遇到'*' has type str, but expected one of: bytes问题的解决

作者头像
sparkexpert
发布2018-01-09 11:54:14
1.7K0
发布2018-01-09 11:54:14
举报

为了对flowers数据集进行训练,于是调用了tensorflow的slim模块中的download_and_convert_flowers.py文件进行处理,

但是下载完成之后,执行过程中碰到一个问题:'jpg' has type str, but expected one of: bytes

看来tensorflow默认的源码都是基于python2环境下的。

而python3环境下是需要额外加个字符的。因此针对这种问题,只能修改源码:

具体修改如下:即在'jpg'前面加一个字母:b,即代表以字节的方式来进行处理。

            example = dataset_utils.image_to_tfexample(                 image_data, b'jpg', height, width, class_id)             tfrecord_writer.write(example.SerializeToString())

修改完,再次执行这个文档,果然顺利通过:

>> Converting image 348/350 shard 4 >> Converting image 349/350 shard 4 >> Converting image 350/350 shard 4 Finished converting the Flowers dataset!

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017年04月18日,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档