【问题标题】:Proper way to define inputshape on the first layer on keras在 keras 的第一层上定义 inputshape 的正确方法
【发布时间】:2018-06-03 07:29:42
【问题描述】:

我有 35000 张 256x256 灰度图像的数组

print(len(data))
>>>35000
print(data[0].shape)
>>>(256, 256)

我的第一层是

model.add(Conv2D(64, (3, 3), input_shape=(35000,), activation='relu'))

它给了我错误

>>>ValueError: Input 0 is incompatible with layer conv2d_1: expected ndim=4, found ndim=2

我做错了什么?定义输入形状的正确方法是什么?

【问题讨论】:

  • 你看docs了吗?
  • 我也试过 (256,256) 但得到了ValueError: Input 0 is incompatible with layer conv2d_1: expected ndim=4, found ndim=3
  • 纠正你丢失的 RGB 颜色,除非你没有这些信息,那么也许你应该使用 Conv1D

标签: python tensorflow deep-learning keras


【解决方案1】:

卷积层输入形状:(images, height, width, channels)

所以:

  • input_shape=(256,256,1)
  • batch_shape=(batch_size,256,256,1)
  • batch_input_shape=(batch_size,256,256,1)

【讨论】:

  • 谢谢,input_shape=(256,256,1) 有效,我需要给出通道数
猜你喜欢
  • 1970-01-01
  • 2020-01-04
  • 2018-07-21
  • 2020-11-28
  • 1970-01-01
  • 1970-01-01
  • 2016-08-25
  • 2021-12-09
  • 2018-12-08
相关资源
最近更新 更多