Git Product home page Git Product logo

Comments (2)

takaaki5564 avatar takaaki5564 commented on September 26, 2024

@stationkl5
返信が遅くなり申し訳ありません。

with torch.no_grad()を必要とした意図としては、このステップでは生成器Gの学習のためのパラメータ計算をしている段階であり、識別器Dのパラメータはここでは更新したくないためです。

もしwith torch.no_grad()が存在しない場合、self.netD(fakeAB)を計算する時に勾配が自動的に計算され、識別器Dのパラメータが意図に反して更新されてしまいます。そのためwith torch.no_grad()が必要となります。

from gan_sample.

stationkl5 avatar stationkl5 commented on September 26, 2024

@takaaki5564
ご回答ありがとうございます。

生成機のパラメーターを、識別機をだませるパラメータに更新するために
lossG_GANを計算して生成機に逆伝搬させたいところですが、
 lossG_GAN=criterionGAN(self.netD(self.netG(A),B)
を逆伝搬したくても
 with torch.no_grad():
  pred_fake = self.netD(fakeAB)
としていると、netDの勾配がないため、netGまで逆伝搬できず、生成機のパラメーターも更新できないのでないでしょうか?

from gan_sample.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.