ValueError: Negative dimension size caused by subtracting 5 from 1 for ‘{{node le_net5/conv2d/Conv2D

简介: ValueError: Negative dimension size caused by subtracting 5 from 1 for ‘{{node le_net5/conv2d/Conv2D
ValueError: Negative dimension size caused by subtracting 5 from 1 for '{{node le_net5/conv2d/Conv2D}} = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], explicit_paddings=[], padding="VALID", strides=[1, 1, 1, 1], use_cudnn_on_gpu=true](le_net5/Cast, le_net5/conv2d/Conv2D/ReadVariableOp)' with input shapes: [32,1,28,28], [5,5,28,6].

使用Tensorflow搭建LeNet5训练Mnist数据集,出错的原因是图像数据维度的问题,输入模型的数据应该是三维,即 (32,32,3)或者(3,32,32),TensorFlow默认接受的是第一种方式,即(width,height,channel)

解决方法:

法一:在(60000,32,32)添加一个维度,填在最后面变成(60000,32,32,3)

train_images = tf.expand_dims(train_images, axis=3)

法二:修改TenforFlow默认指定通道方式

backend.set_image_data_format("channels_first")


目录
相关文章
Glide Caused by: javax.net.ssl.SSLPeerUnverifiedException: Hostname not verified:
Glide Caused by: javax.net.ssl.SSLPeerUnverifiedException: Hostname not verified:
|
8月前
|
网络安全
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "http://xxxx.svc.cluster.local:8080/xxxx": Connection reset; nested exception is java.net.SocketException: Connection reset 什么原因导致得
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST request for "xxxx.svc.cluster.local:8080/xxxx ": Connection reset; nested exception is java.net.SocketException: Connection reset 什么原因导致得
928 0
|
2月前
|
开发工具
933.【开发工具】解决idea:Caused by: java.net.BindException: Add
933.【开发工具】解决idea:Caused by: java.net.BindException: Add
23 2
|
4月前
|
NoSQL Linux 网络安全
解决Caused by: java.net.SocketTimeoutException: connect timed out Exception in thread “main“ redis.cli
解决Caused by: java.net.SocketTimeoutException: connect timed out Exception in thread “main“ redis.cli
|
5月前
|
分布式计算 Linux Spark
【已解决】Caused by: java.net.SocketException: Connection reset by peer: socket write error
【已解决】Caused by: java.net.SocketException: Connection reset by peer: socket write error
77 0
|
Java
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has
246 0
Caused by: java.lang.IncompatibleClassChangeError: class net.sf.cglib.core.DebuggingClassWriter has
|
SQL 分布式计算 Java
Caused by: java.net.ConnectException: Call From master/192.168.199.130 to master:9000 failed on connection exception: java.net.ConnectException: Conne
1:安装好hive,准备启动的时候出现下面的错误(由于hive是基于Hadoop的,所以必须先将你的集群启动起来,我就是没有启动集群,直接启动hive导致的错误): 1 [root@master bin]# .
3999 0
|
分布式计算 Hadoop Linux
一脸懵逼加从入门到绝望学习hadoop之Caused by: java.net.UnknownHostException: master报错
windows下开发hadoop应用程序,hadoop部署在linux环境中, 在运行调试时可能会出现无法找到主机,类似异常信息如下: java.net.UnknownHostException: unknown host: master 解决办法如下: 在C:\WINDOWS\system32\drivers\etc\hosts文件中添加如下信息: 192.
3286 0
|
测试技术
testNG java.net.SocketException: Software caused connection abort: socket write error
执行用例报错,提示 java.net.SocketException: Software caused connection abort: socket write error java.
1564 0
|
分布式数据库 Hbase 容器
Hbase master启动报错:Failed construction of Master: class org.apache.hadoop.hbase.master.HMaster Caused by: java.net.UnknownHostException:
Hbase master启动报错: java.lang.RuntimeException: Failed construction of Master: class org.apache.hadoop.
2640 0