tabensemb.model.AbstractNN.set_requires_grad#

method

AbstractNN.set_requires_grad(model: Module, requires_grad: bool | None = None, state=None)[source]#

Set or reset requires_grad states of a nn.Module.

Parameters:
model

A nn.Module model.

requires_grad

The requires_grad state for all parameters in the model.

state

The recorded state when calling this method with the argument required_grad given.

Returns:
list

The recorded state that can be used as the argument “state” to restore requires_grad states of the same model. Returned when the argument requires_grad is given.