chainerx.force_backprop_mode¶
- chainerx.force_backprop_mode()¶
Creates a context manager which temporarily enables backpropagation.
This context re-enables backpropagation that is disabled by any surrounding
no_backprop_mode()
context.x = chainerx.array([4, 3], numpy.float32) x.require_grad() with chainerx.no_backprop_mode(): with chainerx.force_backprop_mode(): y = 2 * x + 1 y.backward() x.grad # array([2., 2.], shape=(2,), dtype=float32, device='native:0')