MCPcopy Create free account
hub / github.com/huggingface/transformers / assert_all_frozen

Function assert_all_frozen

examples/seq2seq/utils.py:252–256  ·  view source on GitHub ↗
(model)

Source from the content-addressed store, hash-verified

250
251
252def assert_all_frozen(model):
253 model_grads: List[bool] = list(grad_status(model))
254 n_require_grad = sum(lmap(int, model_grads))
255 npars = len(model_grads)
256 assert not any(model_grads), f"{n_require_grad/npars:.1%} of {npars} weights require grad"
257
258
259def assert_not_all_frozen(model):

Callers 2

Calls 2

grad_statusFunction · 0.85
lmapFunction · 0.70

Tested by

no test coverage detected