conv2D层keras造成的数据形状错误

时间:2018-11-20 11:01:26

标签: python keras conv-neural-network reshape shapes

我是神经网络的重要人物, 跑步时出现以下错误

ValueError:检查目标时出错:预期conv2d_1具有形状(64,222,222)但具有形状(1,224,224)的数组

据我所知,我使用灰度图像,我认为我正在正确调整输入的形状。 我无法理解我在做什么。

这是网络的摘录

网络模型:

select * from tablename a
where created_at in 
(select max(created_at) from tablename b where a.user_id=b.user_id)
order by points desc limit 50

读取数据:

def convLayer(channels):
  return

Conv2D(channels,kernel_size=3,activation='relu',\
 kernel_initializer=initializers.random_normal(mean=0.0, stddev=0.01),\ 
  data_format='channels_first')

class est_net():

  def __init__(self, input=None):
    if input is None:
        input=Input(shape=(1,224,224))
    self.input=input

    conv1_1 = convLayer(64)(self.input)

    self.output = conv1_1
    self.CDECNN = Model(inputs=self.input, outputs=self.output)
    print(self.CDECNN.summary())

培训:

def __iter__(self):
    files=self.img_files
    for f in files:
        if f==".DS_Store":
            continue
        img=cv2.imread(os.path.join(self.img_path,f),cv2.COLOR_BGR2GRAY)
        img=img.reshape(1, img.shape[0], img.shape[1])
        if img is None:
            print("unable to read image %s." % f)
            exit(0)
        gt_file='GT_'+f.split('.')[0]+'.mat'
        gt=sio.loadmat(os.path.join(self.gt_path,gt_file))['d_map']
        gt=gt.reshape(1, gt.shape[0], gt.shape[1])
        yield(img,gt)

0 个答案:

没有答案