On a forward propagation, Chainer normally stores all intermediate results
of VariableNodes on a computational graph as
they are required on backward propagation.
Sometimes these results consume too much memory.
F.forgetforgets such intermediate results on forward propagation,
and still supports backpropagation with recalculation.

On a forward propagation, F.forget calls a given function with given
variables without creating a computational graph. That means, no
intermediate results are stored.
On a backward propagation, F.forget calls the given function again to
create a computational graph for backpropagation.

F.forget reduces internal memory usage, whereas it requires more
calculation time as it calls the function twice.

In case input argument variables are of N-dimensional array objects,
arguments will automatically be
converted to Variables.
This conversion takes place to ensure that this function is included
in the computational graph to enable backward computations.

Note

F.forget does not support double backpropagation.

Note

If you want to use F.forget to a link which updates the link’s
internal information every time the forward computation is called,
please ensure that the information is updated just once in a single
iteration. You may use the chainer.config.in_recomputing flag to
check if the forward computation is the first call in an iteration.
Please see the implementation of
BatchNormalization for detail.

Parameters

func (callable) – A function to call. It needs to be called with
Variable object(s) and to return a
Variable object or a tuple of
Variable objects.