2018-03-13-Cycle GAN with tensorflow (1)


Reference:
Github


Class Cycle Gan


_init

+discriminator (ResNet/VGG19)
++D_A
++D_B
+generator (ResNet/VGG19)
++G_A2B
++G_B2A
+criterion (MAE/LS)

_judge

+real_A
++loss
+real_B
++loss
+fake_A_from_real_B # generator, to generate fake A from real B
+fake_A_from_fake_B # generate fake A from fake B
++loss
+fake_B_from_real_A # generate fake B from real A
++loss
+fake_B_from_fake_A # generate fake B from fake A
++loss
+fake_A_sample
#what the difference between fake_A_from_real_B or fake_A_from_fake_B and fake_A_sample
+fake_B_sample


in discriminator

+D_A_real # call discriminator, to discriminate real_A
++D_A_real_loss # call criterion to compare D_A_real and ground truth
+D_B_real # call discriminator, to discriminate real_B
++D_B_real_loss # call criterion to compare D_B_real and ground truth
+D_A_fake # call discriminator, to discriminate fake_A_from_real_B
++D_A_fake_loss # call criterion to compare D_A_fake and ground truth
#D_A_loss = f.(D_A_real_loss, D_A_fake_loss)
+D_B_fake # call discriminator, to discriminate fake_B_from_real_A
++D_B_fake_loss # call criterion to compare D_B_fake and ground truth
#D_B_loss = f.(D_B_real_loss, D_B_fake_loss)
+D_A_fake_sample # call discriminator, to discriminate fake_A_sample
++D_A_fake_sample_loss # call criterion to compare D_A_fake_sample and ground truth
+D_B_fake_sample # call discriminator, to discriminate fake_B_sample
++D_B_fake_sample_loss # call criterion to compare D_B_fake_sample and ground truth
#D_loss = f.(D_A_loss, D_B_loss)
#why not use D_B_fake_from_fake_A? because here only fake_A_from_fake_B be used


in generator

G_loss_A2B # call the criterion to compare DB_fake and fake ground truth, because the goal of generator is to cheat the D_B.
so that G_loss_A2B= f.((DE_fake,fake ground truth),(λ, real_A,fake_A_from_fake_B),(λ,real_B,fake_B_from_fake_A)) # λ controls the relative importance of the two objectives, fake_B_from_fake_A more like B or fake_A_from_fake_B more like A

G_loss_B2A # f(DA_fake,real_A,fake_A_from_fake_B,real_B,fake_B_from_fake_A)
G_loss_All # f(DA_fake, DB_fake, real_A,fake_A_from_fake_B,real_B,fake_B_from_fake_A)

loss function

loss function

full objective

training details


summary and record

in discriminator
+D_A_real_loss_summary # call tf.summary.scalar to summary and record the D_A_real_loss
+D_A_fake_loss_summary # call tf.summary.scalar to summary and record the D_A_fake_loss
+D_A_loss_summary # call tf.summary.scalar to summary and record the D_A_loss
+D_B_real_loss_summary # call tf.summary.scalar to summary and record the D_B_real_loss
+D_B_fake_loss_summary # call tf.summary.scalar to summary and record the D_B_fake_loss
+D_B_loss_summary # call tf.summary.scalar to summary and record the D_B_loss
+D_loss_summary # call tf.summary.scalar to summary and record the D_loss

in generator
+G_loss_A2B_summary # call tf.summary.scalar to summary and record the G_loss_A2B
+G_loss_B2A_summary # call tf.summary.scalar to summary and record the G_loss_B2A
+G_loss_summary # call tf.summary.scalar to summary and record the G_loss


in train.py

#Update G network and record fake outputs
fake_A, fake_B, _, summary_str = self.sess.run(
[self.fake_A, self.fake_B, self.g_optim, self.g_sum],
feed_dict={self.real_data: batch_images, self.lr: lr})

#Update D network
_, summary_str = self.sess.run(
[self.d_optim, self.d_sum],
feed_dict={self.real_data: batch_images,
self.fake_A_sample: fake_A,
self.fake_B_sample: fake_B,self.lr: lr})


to be continued

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 今天起,我和寶貝妞要共同學習、天天進步啦!現(xiàn)在我拿起一本書,說:“我要看書了,寶貝你和我一起嗎?”寶貝妞開心...
    寶貝雨點兒閱讀 278評論 0 0
  • On this pageDatabasesCollections MongoDB stores BSON docu...
    x丶ST閱讀 613評論 0 1
  • 宏觀不二略同之世界(大我);微觀不同異樣世界之縮影(小我)。略標本來十個小小的優(yōu)點-作業(yè)。 01、珍惜眾生命;02...
    真如自在閱讀 164評論 1 3
  • /亞麻籽油由亞麻籽制取而成,亞麻籽是亞麻的籽實,屬亞麻科別稱胡麻 ,原產(chǎn)于東印度地區(qū),漢朝張騫出使西域之時,經(jīng)絲綢...
    胖美眉閱讀 1,138評論 0 0

友情鏈接更多精彩內(nèi)容