MCPcopy Create free account
hub / github.com/MotrixLab/FineMoGen / set_requires_grad

Function set_requires_grad

mogen/models/utils/misc.py:1–14  ·  view source on GitHub ↗

Set requies_grad for all the networks. Args: nets (nn.Module | list[nn.Module]): A list of networks or a single network. requires_grad (bool): Whether the networks require gradients or not

(nets, requires_grad=False)

Source from the content-addressed store, hash-verified

1def set_requires_grad(nets, requires_grad=False):
2 """Set requies_grad for all the networks.
3
4 Args:
5 nets (nn.Module | list[nn.Module]): A list of networks or a single
6 network.
7 requires_grad (bool): Whether the networks require gradients or not
8 """
9 if not isinstance(nets, list):
10 nets = [nets]
11 for net in nets:
12 if net is not None:
13 for param in net.parameters():
14 param.requires_grad = requires_grad
15
16
17def zero_module(module):

Callers 2

build_text_encoderMethod · 0.90
__init__Method · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected