基于TensorFlow训练mnist数据集出现如下错误:

检测代码,发现是偏置设置格式错误导致。

1、错误代码:

# 定义权重和偏置
n_input = 784
n_output = 10
weights = {'wc1': tf.Variable(tf.random_normal([3, 3, 1, 64], stddev=0.1)),'wc2': tf.Variable(tf.random_normal([3, 3, 64, 128], stddev=0.1)),'wd1': tf.Variable(tf.random_normal([7 * 7 * 128, 1024], stddev=0.1)),'wd2': tf.Variable(tf.random_normal([1024, n_output], stddev=0.1))
}
biases = {'bc1': tf.Variable(tf.random_normal(64), stddev=0.1),'bc2': tf.Variable(tf.random_normal(128), stddev=0.1),'bd1': tf.Variable(tf.random_normal(1024), stddev=0.1),'bd2': tf.Variable(tf.random_normal(n_output), stddev=0.1)
}

2、修改后的代码如下:

把biases的"()"改为"[]"

#定义权重和偏置
n_input = 784
n_output= 10
weights = {'wc1':tf.Variable(tf.random_normal([3,3,1,64], stddev=0.1)),'wc2':tf.Variable(tf.random_normal([3,3,64,128],stddev=0.1)),'wd1':tf.Variable(tf.random_normal([7*7*128,1024],stddev=0.1)),'wd2':tf.Variable(tf.random_normal([1024,n_output],stddev=0.1))
}
biases = {'bc1':tf.Variable(tf.random_normal([64], stddev=0.1)),'bc2':tf.Variable(tf.random_normal([128],stddev=0.1)),'bd1':tf.Variable(tf.random_normal([1024],stddev=0.1)),'bd2':tf.Variable(tf.random_normal([n_output],stddev=0.1))
}

【TensorFlow】ValueError: Shape must be rank 1 but is rank 0 for ' ’ with input shapes: [].问题相关推荐

  1. 人工智障与深度学渣之问题集锦:ValueError: Shape must be rank 4 but is rank 1 for 'Conv2D' with input shapes。。。

    醉最近在写网络的时候,总会遇到一些坑,虽然大部分都能百度到,但还是有一些坑让我郁闷.比较好久没写网络了,以前的填坑经验也都忘了.比如这里的报错: ValueError: Shape must be r ...

  2. keras报错 ValueError: Shape must be rank 1 but is rank 0 for 'bn_conv1/Reshape_4' (op: 'Reshape') 不用降级

    问题:ValueError: Shape must be rank 1 but is rank 0 for 'bn_conv1/Reshape_4' (op: 'Reshape') with inpu ...

  3. ValueError: Shape mismatch: The shape of labels (received (768,)) should equal the shape of logits e

    问题 运行tensorflow 的resnet网络,预测结果,出现报错 ValueError: Shape mismatch: The shape of labels (received (768,) ...

  4. 成功解决ValueError: Shape of passed values is (33, 1), indices imply (33, 2)

    成功解决ValueError: Shape of passed values is (33, 1), indices imply (33, 2) 目录 解决问题 解决思路 解决方法 解决问题 Valu ...

  5. 成功解决ValueError: Cannot feed value of shape (80, 15, 1, 1) for Tensor 'Placeholder_1:0', which has sh

    成功解决ValueError: Cannot feed value of shape (80, 15, 1, 1) for Tensor 'Placeholder_1:0', which has sh ...

  6. 成功解决ValueError: Shape of passed values is (1, 332), indices imply (1, 1)

    成功解决ValueError: Shape of passed values is (1, 332), indices imply (1, 1) 目录 解决问题 解决思路 解决方法 解决问题 Valu ...

  7. 已解决ValueError: Shape of passed values is (1509, 1), indices imply (1509, 2)

    已解决(pandas创建DataFrame对象失败)ValueError: Shape of passed values is (1509, 1), indices imply (1509, 2) 文 ...

  8. 已解决ValueError: Shape of passed values is (6, 3), indices imply (4, 3)

    已解决(pd.concat连接错误)ValueError: Shape of passed values is (6, 3), indices imply (4, 3) 文章目录 报错代码 报错翻译 ...

  9. 解决ValueError: Shape of passed values is (1,5), indices imply (1,3)

    报错部分代码: MetricsDataFrame = pd.DataFrame(Metrics,columns=np.tile(MetricNames, datasetNum),index=exper ...

最新文章

  1. Linux之facl
  2. 负载均衡集群ipvsadm命令及基本用法
  3. Zabbix安装(server和agent)及基本配置
  4. php设计之初用于什么,PHP设计模式(七)之门面模式
  5. Git常用命令——基本操作
  6. FreeSWITCH 下载地址
  7. 教你6步定制你的Ubuntu桌面
  8. c++指针详解_c语言详解sizeof
  9. Python IndentationError: expected an indented block
  10. 【信息安全】-身份认证技术
  11. 关于Python的静态变量
  12. 苦过 痛过 一笑而过
  13. linux中execve函数的用法
  14. UCC27201DDAR
  15. 程序员的算法趣题Q25: 时髦的鞋带系法
  16. 英文SEO站群操作模式介绍
  17. 【蓝牙串口 】【Ubuntu】Python脚本蓝牙串口连接并解决权限问题
  18. 联迪商用中标民生银行小微金融部智能POS采购项目
  19. 终极USB示波器PicoScope 6000系列
  20. 6.17黄金反弹是否到顶,下周开盘如何布局

热门文章

  1. matlab潮流程序,IEEE33节点matlab潮流程序.doc
  2. 微信小程序textArea组件字数限制
  3. 【新星计划】MATLAB系统辨识工具箱使用方法
  4. 2021-02-25 matlab 字符串和数字同时写入excel
  5. webpack4--提取css到单独文件并且压缩css
  6. php能调用easyui窗口,关于jQuery EasyUI window窗口使用实例详解
  7. hw叠加层开还是不开_HW叠加层是什么?
  8. [Google Guava] 11-事件总线
  9. Vue.js 单文件组件
  10. [MySQL] 索引与性能(3)- 覆盖索引