关于input to reshape is a tensor 的问题

2023-05-16


for index, name in enumerate(classes):
    class_path = cwd + name +'/'
    for img_name in os.listdir(class_path):
        img_path = class_path + img_name  # 每一个图片的地址

        img = Image.open(img_path)
        img = img.resize((448, 448))
        img_raw = img.tobytes()  # 将图片转化为二进制格式
        example = tf.train.Example(features=tf.train.Features(feature={
            "label": tf.train.Feature(int64_list=tf.train.Int64List(value=[index])),
            'img_raw': tf.train.Feature(bytes_list=tf.train.BytesList(value=[img_raw]))
        }))  # example对象对label和image数据进行封装
        writer.write(example.SerializeToString())  # 序列化为字符串

writer.close()

img.resize((a,b))确实是与Input to reshape is a tensor with X values相关,经过多出实验的结果是:X=(a*b)*0.75,至于为什么是这样目前还不知道。

剩下的就是根据报错来改了些参数,就是tensor有些不一样。
但到了这里就不知道应该怎么改了:

Traceback (most recent call last):
  File "mobile.py", line 67, in <module>
    train_acc=accuracy.eval(feed_dict={x: img_xs, y_: label_xs})
  File "/home/sys-04/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 569, in eval
    return _eval_using_default_session(self, feed_dict, self.graph, session)
  File "/home/sys-04/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3741, in _eval_using_default_session
    return session.run(tensors, feed_dict)
  File "/home/sys-04/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 778, in run
    run_metadata_ptr)
  File "/home/sys-04/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 961, in _run
    % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (20,) for Tensor 'one_hot:0', which has shape '(?, 2)'

尝试了以下:

#y_ = tf.placeholder(tf.float32, shape=[None, 2])
y = tf.placeholder(tf.int32, [None])
y_ = tf.one_hot(y,2)

但是依然如此。
明天继续囖!!!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

关于input to reshape is a tensor 的问题 的相关文章

随机推荐

  • 【playwright】使用playwright实现拖动功能

    思路说明 使用locator定位到要拖动滑块元素 xff0c 如元素名叫ele 获取元素ele的bounding box含4分属性值 xff1a x xff0c y xff0c width xff0c height 把鼠标移动到元素ele的
  • 【playwright】pytest-playwright与allure结合,生成报告带有图片和录屏

    依赖的环境 需要安装allure命令行工具以及allure pytest插件 pytest playwright需要升级0 3 0版本 xff0c 改版本支持如下参数 xff1a Playwright browser 61 chromium
  • 【性能测试】缓慢的磁盘问题分析套路

    该文基于 性能之巅 xff1a 洞悉系统 企业与云计算 的1 9 1 缓慢的磁盘章节调整而来 用户问题 Scott 是一家中型公司里的系统管理员 数据库团队报告了一个支持ticket xff08 工单 xff09 xff0c 抱怨他们有一台
  • 【虚拟机】win 10的virtual box打开虚拟机报VERR_MEM_INIT_FAILED

    错误信息 解决办法 进入到 控制面板 程序 程序和功能 xff1a 选择 启用或关闭 Windows 功能 xff1a 重启电脑 xff0c 重新打开virtual下的虚拟机 xff0c 能够正常启动 xff1a
  • 【playwright】pytest-playwright增加代理服务选项

    playwright的代理设置参数为 xff1a https playwright dev python docs network http proxy 对pytest playwright py进行如下调整 xff0c 在browser
  • 【镜像源】分享三个镜像链接

    兰州大学 xff1a https mirror lzu edu cn 南京大学 xff1a https mirror nju edu cn docker官方镜像库 xff1a https github com docker library
  • 【Docker】基于系统iso构建docker基础镜像

    1 搭建本地yum源 1 xff09 将镜像通过光盘或U盘挂载到 mnt目录下 mount media kylin xxx iso mnt kylin 2 xff09 修改 etc yum repo d kylin x86 64 local
  • 【数据库】Oracle 12透明网关查询postgresql表某些字段不展示问题处理

    前置条件 1 对应版本列表 服务 版本 Oracle 12C 12 2 0 1 0 Heterogeneous Agent 12 2 0 1 0 odbc 2 3 1 unixODBC 2 3 6 psqlodbc 9 2 24 查看命令
  • 【机器学习】lightGBM是什么?

    梯度提升法 Gradient Boosting Machine 简记 GBM 以非参数方法 不假设函数形式 估计基函数 并在 函数空间 使用 梯度下降 进行近似求解 非参数方法包括K近邻法 决策树 以及基于决策树的装袋法 随机森林与提升法等
  • 【HttpRunner】学习准备

    1 安装python 3 7及以上版本 xff1a 2 安装fastapi xff1a pip install fastapi all 3 把如下代码粘贴复制到main py文件中 xff1a span class token keywor
  • Android中锁定文件的方法

    androidSDK中并没有锁定文件相关的api 但是android是基于linux操作系统的 linux比较底层 灵活性也更大 为了实现锁定文件的效果 大概有以下几种办法 用chmod命令修改文件读写权限利用linux中的多线程独占锁 启
  • 远程控制Ubuntu

    远程控制Ubuntu 在Ubuntu上安装team viewer或者向日葵 xff0c 进行远程控制 xff0c 这里记录采用team viewer方式的配置过程 xff0c 向日葵等远程控制类似 安装Ubuntu 官方下载Ubuntu系统
  • 信号降噪方法

    傅里叶变换 只能获取一段信号总体上包含哪些频率的成分 xff0c 但是对各成分出现的时刻并无所知 对非平稳过程 xff0c 傅里叶变换有局限性 短时傅里叶变换 xff08 Short time Fourier Transform STFT
  • C++ 带通滤波

    Butterworth Filter Coefficients The following files are for a library of functions to calculate Butterworth filter coeff
  • python之collections

    collections是日常工作中的重点 高频模块 xff0c 包含了一些特殊的容器 xff0c 针对Python内置的容器 xff0c 例如list dict set和tuple xff0c 常用类型有 xff1a namedtuple
  • git 指定下载文件,目录

    1 创建路径 mkdir gitfile cd lt 路径 gt eg xff1a cd home gitfile 2 创建一个空的本地仓库 git init 3 连接远程仓库GitHub git remote add f origin l
  • Ubuntu v4l2 视屏流花屏问题

    之前用的好好解析YUV xff0c MJPEG 换了个核心板就不好使了 xff0c opencv3 4 6 gt gt gt opencv4 5 5 xff0c Mat xff0c cvMat xff0c IplImage 的类型转换也不好
  • qt qmake .qrc hasmodification time xxx in the future

    原因 xff1a 跨平台生成的 qrc 文件创建时间与目标平台时间不一致导致 xff0c 如win写的 copy 到 Linux xff0c 再编译可能会遇到该bug 导致无法qmake 与 build 解决 xff1a touch qrc
  • (转)python图像操作

    转自 xff1a zbxzc 侵删 使用PIL完成 python view plain copy span class hljs keyword import span Image span class hljs comment 打开图像
  • 关于input to reshape is a tensor 的问题

    span class hljs keyword for span index name span class hljs operator in span enumerate classes class path 61 cwd 43 name