组合GAN函数期望输入轴为-1.在Jupyter工作,而不是在Colab



我一直在使用ciphar-10 GAN,它在Jupyter笔记本电脑中运行良好,但在Colab中我收到了错误:

层sequencial_9的输入0与层不兼容:预期输入形状的轴-1具有值1,但接收到具有形状的输入[无,32,32,3]

我想我需要重塑它,但我不确定为什么它在Jupyter中有效。任何建议都会有所帮助。

发电机型号的代码如下:

def define_generator(latent_dim):
model = Sequential()
# foundation for 4x4 image
n_nodes = 256 * 4 * 4
model.add(Dense(n_nodes, input_dim=latent_dim))
model.add(LeakyReLU(alpha=0.2))
model.add(Reshape((4, 4, 256)))
# upsample to 8x8
model.add(Conv2DTranspose(128, (4,4), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
# upsample to 16x16
model.add(Conv2DTranspose(128, (4,4), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
# upsample to 32x32
model.add(Conv2DTranspose(128, (4,4), strides=(2,2), padding='same'))
model.add(LeakyReLU(alpha=0.2))
# output layer
model.add(Conv2D(3, (3,3), activation='tanh', padding='same'))
return model

谢谢。(型号:"sequential_10与sequential 9相同"(

模型摘要和错误

查看是否加载RGB图像(3个通道(而不是灰度(1个通道(。

最新更新