我想用2d dcgan构建3d dcgan。虽然一切都适用于2d,但在3d中尝试训练生成器时出现尺寸错误。可悲的是,抛出的错误是非常神秘的,我无法从中做出很多贡献:
2019-05-26 17:47:47.992134:F。\ tensorflow / core / util / mkl_util.h:607] 检查失败:暗淡== size.size()(5比4)
到目前为止,我检查了每个模型是否都可以独立运行,并且可以运行。正如预期的那样,生成器给了我一个立方体,而鉴别器也完成了它的工作。我尝试查找mkl_util标头。
这是我的初始化:
def __init__(self):
# Input shape
self.axis = 16
self.channels = 1
self.img_shape = (self.axis, self.axis, self.axis, self.channels)
self.dimensions = 500
optimizer = tf.keras.optimizers.Adam(0.0002, 0.5)
self.discriminator = self.build_discriminator()
self.discriminator.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])
self.generator = self.build_generator()
z = tf.keras.layers.Input(shape=(self.dimensions,))
img = self.generator(z)
self.discriminator.trainable = False
valid = self.discriminator(img)
self.combined = tf.keras.models.Model(z, valid)
self.combined.compile(loss='binary_crossentropy', optimizer=optimizer)
而且,这里发生了错误self.combined.train_on_batch(noise, valid)
valid = np.ones((batch_size, 1))
noise = np.random.normal(0, 1, (batch_size, self.dimensions))
g_loss = self.combined.train_on_batch(noise, valid)
由于生成模型本身会运行,因此判别器也不会。”