Giter Club home page Giter Club logo

Comments (5)

cwarny avatar cwarny commented on July 27, 2024 2

Wouldn't it be better to detach the fake data here:

fake_validity = discriminator(fake_imgs)

fake_validity = discriminator(fake_imgs.detach())

We don't want to calculate gradients for the generator when doing backpropagation on the critic:

Although it doesn't matter in practice since we later zero out the gradients here:

optimizer_G.zero_grad()

It still introduces unnecessary computation. Or is there a reason we don't want to detach that I'm missing?

from pytorch-gan.

eriklindernoren avatar eriklindernoren commented on July 27, 2024 1

I see no problem in this case (although using .detach() wouldn't hurt). Neither real_samples or fake_samples are used for the backward pass. I.e. the fact that real_samples.detach() has the benefit of having it's in-place changes reported by autograd should make no difference as real_samples is not used.

from pytorch-gan.

eriklindernoren avatar eriklindernoren commented on July 27, 2024

They are already detached since they are fed to the function as real_imgs.data, fake_imgs.data.

from pytorch-gan.

Oktai15 avatar Oktai15 commented on July 27, 2024

@eriklindernoren I am not sure about it.
pytorch/pytorch#6990

What do you think about this issue?

from pytorch-gan.

annan-tang avatar annan-tang commented on July 27, 2024

@cwarny I agree with you! My answer is similar to yours, here

from pytorch-gan.

Related Issues (20)

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.