Git Product home page Git Product logo

Comments (13)

soumith avatar soumith commented on July 30, 2024

it simply shares the .output buffer for every alternating module. So in total only two .output buffers are needed for the whole network. This can be done in the inference phase, where we dont need to keep around the .output for backward computation.

from dcgan.torch.

kmul00 avatar kmul00 commented on July 30, 2024

From what I understand, we need the .output during backward computation because the output for the current layer, acts as input to the next layer.

In that case, why exactly do we need to share every alternating module (have two buffers), instead of just having one buffer ?

from dcgan.torch.

soumith avatar soumith commented on July 30, 2024

because while you are computing a layer, you cant have it's input and output be the same. As you write to the output, you cant read from the output and expect it to be input.

from dcgan.torch.

dasguptar avatar dasguptar commented on July 30, 2024

So, is it possible to set up double buffering for training? Would the required changes simply involve having buffers for gradInput instead of output?

from dcgan.torch.

soumith avatar soumith commented on July 30, 2024

yea you can (for gradInput), but it requires a little bit of change to our method dispatch in backward.
In current backward, all modules' updateGradInput is called, and then all modules' accGradParameters.
This has to be changed such that gradInput dependencies are better scoped.

We have internal patches for this, will open PRs slowly and patch things.

from dcgan.torch.

fmassa avatar fmassa commented on July 30, 2024

@soumith I think that currently all modules in nn/cunn do not use gradInput in accGradParameters (and that should be always the case except for rare optimizations), so optimizing gradInput for memory is already possible. Even the newly added SpatialBatchNormalization (which implements only a backward in C) would work.
Or am I missing something ?

from dcgan.torch.

soumith avatar soumith commented on July 30, 2024

cc: @sgross see fmassa's comment wdyt

from dcgan.torch.

fmassa avatar fmassa commented on July 30, 2024

@soumith did you mean @colesbury ?

from dcgan.torch.

soumith avatar soumith commented on July 30, 2024

oops, yea. sgross is his internal username.

from dcgan.torch.

colesbury avatar colesbury commented on July 30, 2024

@fmassa, it also requires all nn.Containers to properly override 'backward' so that they call 'backward' on their submodules. Some, like nn.Sequential, already do this, but others, like nn.ConcatTable, do not.

from dcgan.torch.

fmassa avatar fmassa commented on July 30, 2024

@colesbury that's needed if we want to optimize backward for speed (by avoiding redundant calls in updateGradInput and accGradParameters).
If what we want is to optimize for space, then I think it's not needed, because gradInput is not used in accGradParameters, I think this refactoring to allow sharing the gradInputs is not needed (but care must be take with parallel containers)

from dcgan.torch.

soumith avatar soumith commented on July 30, 2024

@fmassa accGradParameters uses gradOutput, even though it doesn't use gradInput. If we share gradInput among all alternating layers, now do you see the problem....

from dcgan.torch.

fmassa avatar fmassa commented on July 30, 2024

Ops... you are right. My bad..

from dcgan.torch.

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.