我有一个像这样的甘
generator = Model(g_in, g_out)
generator.compile(...)
discriminator = Model(d_in, d_out)
discriminator.trainable = True
discriminator.compile(..)
discriminator.trainable = False
gan = Model(inputs=.., outputs=..)
gan.compile(..)
#iterate over epochs and batches, without compiling
它学习并给出可接受的输出。但是我收到警告:
“keras\engine\training.py:490: UserWarning: Discrepancy between trainable weights and collectable weights, did you set model.trainable
without call model.compile
after?'可训练权重和收集的可训练权重之间的差异'”
如果我每批次重新编译鉴别器和 gan,警告就会消失,但一次迭代需要更长的时间,训练速度也会更慢。
for epoch:
for batch:
fakes=generator.predict_on_batch(batch)
discriminator.trainable = True
discriminator.compile(..)
discriminator.train_on_batch(batch, ..)
discriminator.train_on_batch(fakes, ..)
discriminator.trainable = False
discriminator.compile(..)
gan.compile(..)
gan.train_on_batch(batch,..)
其中哪一项是正确的?