MCPcopy Create free account
hub / github.com/YesianRohn/TextSSR / loss_and_grad

Function loss_and_grad

diffusers/examples/controlnet/train_controlnet_flax.py:944–949  ·  view source on GitHub ↗
(grad_idx, train_rng)

Source from the content-addressed store, hash-verified

942 )
943
944 def loss_and_grad(grad_idx, train_rng):
945 # create minibatch for the grad step
946 minibatch = get_minibatch(batch, grad_idx) if grad_idx is not None else batch
947 sample_rng, train_rng = jax.random.split(train_rng, 2)
948 loss, grad = grad_fn(state.params, minibatch, sample_rng)
949 return loss, grad, train_rng
950
951 if args.gradient_accumulation_steps == 1:
952 loss, grad, new_train_rng = loss_and_grad(None, train_rng)

Callers 2

train_stepFunction · 0.85
cumul_grad_stepFunction · 0.85

Calls 1

get_minibatchFunction · 0.85

Tested by

no test coverage detected