ValueError: la capa `Concatenate` requiere entradas con formas coincidentes excepto para el eje concat

Estoy intentando construir una Pix2Pix para mi proyecto y obtengo el error:

ValueError: la capa de Concatenate requiere entradas con formas coincidentes, excepto el eje concat. Entradas de formas: [(Ninguna, 64, 64, 128), (Ninguna, 63, 63, 128)]

El generador es un modelo U-net y mis entradas altura x ancho x canales, que es 256,256,3 (X_train) y 256, 256, 1 (Y_train). No lo estoy si el error se debe al preprocesamiento o al modelo en sí. Cualquier ayuda sería muy apreciada.

 def build_generator(self): """U-Net Generator""" def conv2d(layer_input, filters, f_size=3, bn=True): """Layers used during downsampling""" d = Conv2D(filters, kernel_size=f_size, strides=2, padding='same')(layer_input) d = LeakyReLU(alpha=0.2)(d) if bn: d = BatchNormalization(momentum=0.8)(d) return d def deconv2d(layer_input, skip_input, filters, f_size=3, dropout_rate=0): """Layers used during upsampling""" u = UpSampling2D(size=2)(layer_input) u = Conv2D(filters, kernel_size=f_size, strides=1, padding='same', activation='relu')(u) if dropout_rate: u = Dropout(dropout_rate)(u) u = BatchNormalization(momentum=0.8)(u) u = Concatenate()([u, skip_input]) return u # Image input d0 = Input(shape=self.img_shape) # Downsampling d1 = conv2d(d0, self.gf, bn=False) d2 = conv2d(d1, self.gf*2) d3 = conv2d(d2, self.gf*4) d4 = conv2d(d3, self.gf*8) d5 = conv2d(d4, self.gf*8) d6 = conv2d(d5, self.gf*8) d7 = conv2d(d6, self.gf*8) # Upsampling u1 = deconv2d(d7, d6, self.gf*8) u2 = deconv2d(u1, d5, self.gf*8) u3 = deconv2d(u2, d4, self.gf*8) u4 = deconv2d(u3, d3, self.gf*4) u5 = deconv2d(u4, d2, self.gf*2) u6 = deconv2d(u5, d1, self.gf) u7 = UpSampling2D(size=2)(u6) output_img = Conv2D(self.channels, kernel_size=3, strides=1, padding='same', activation='tanh')(u7) return Model(d0, output_img) 

Error de rastreo a continuación:

 --------------------------------------------------------------------------- ValueError Traceback (most recent call last)  in () ----> 1 gan = Pix2Pix() 2 gan.train(epochs=30000, batch_size=1, save_interval=200)  in __init__(self) 48 49 # Build and compile the generator ---> 50 self.generator = self.build_generator() 51 self.generator.compile(loss='binary_crossentropy', optimizer=optimizer) 52  in build_generator(self) 107 u3 = deconv2d(u2, d4, self.gf*8) 108 u4 = deconv2d(u3, d3, self.gf*4) --> 109 u5 = deconv2d(u4, d2, self.gf*2) 110 u6 = deconv2d(u5, d1, self.gf) 111  in deconv2d(layer_input, skip_input, filters, f_size, dropout_rate) 87 u = Dropout(dropout_rate)(u) 88 u = BatchNormalization(momentum=0.8)(u) ---> 89 u = Concatenate()([u, skip_input]) 90 return u 91 /usr/local/lib/python3.5/site-packages/keras/engine/topology.py in __call__(self, inputs, **kwargs) 569 self.build(input_shapes[0]) 570 else: --> 571 self.build(input_shapes) 572 self.built = True 573 /usr/local/lib/python3.5/site-packages/keras/layers/merge.py in build(self, input_shape) 275 'inputs with matching shapes ' 276 'except for the concat axis. ' --> 277 'Got inputs shapes: %s' % (input_shape)) 278 279 def call(self, inputs): ValueError: `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, 64, 64, 128), (None, 63, 63, 128)] 

Intenta definir el formato de datos de la imagen.

 from keras import backend as K K.set_image_data_format('channels_first') 

Creo que esto debería resolver su problema.