我有一个正常的CNN架构,它采用较小的CNN(d64)作为参数。代码:
def discriminator128(d64,a_ch, b_ch, nf, opt=Adam(lr=2e-4, beta_1=0.5), name='d128'):
i = Input(shape=(a_ch + b_ch, 128, 128))
downscaled = AveragePooling2D(pool_size=(2, 2))(i)
conv3 = Convolution(nf*4)(i)
x = LeakyReLU(0.2)(conv3)
conv3 = Convolution1(a_ch+b_ch)(x)
conv3 = LeakyReLU(0.2)(conv3)
in1 = Lambda(lambda x: x * d128_var1in)(downscaled)
in2 = Lambda(lambda x: x* d128_var2in)(conv3)
in64 = Add()([in1,in2])
out = d64(in64)
d = Model(i, out, name=name)
def d_loss(y_true, y_pred):
L = objectives.binary_crossentropy(K.batch_flatten(y_true),
K.batch_flatten(y_pred))
return L
d.compile(optimizer=opt, loss=d_loss)
return d
我收到了这个错误:
ValueError: GpuElemwise. Input dimension mis-match. Input 1 (indices start at 0) has shape[0] == 1, but the output's size on that axis is 2.