chainerx.no_backprop_mode¶
-
chainerx.
no_backprop_mode
()¶ Creates a context manager which temporarily disables backpropagation.
Within this context, no computational graph will be formed unless
force_backprop_mode()
is used.Arrays resulting from operations enclosed with this context will be disconnected from the computational graph. Trying to perform backpropagation from such arrays would result in an error.
x = chainerx.array([4, 3], numpy.float32) x.require_grad() with chainerx.no_backprop_mode(): y = 2 * x + 1 y.backward() # ! error
Benefits of
no_backprop_mode
include reduced CPU overhead of building computational graphs, and reduced consumption of device memory that would be otherwise retained for backward propagation.