# `Tinkex.Types.RegularizerOutput`
[🔗](https://github.com/North-Shore-AI/tinkex/blob/v0.4.0/lib/tinkex/types/regularizer_output.ex#L1)

Output metrics from a single regularizer computation.

This struct captures both the loss contribution and optional gradient
tracking information for monitoring regularizer dynamics.

## Fields

- `:name` - Regularizer name (matches RegularizerSpec.name)
- `:value` - Raw loss value before weighting
- `:weight` - Weight applied to the loss
- `:contribution` - Weighted contribution: `weight * value`
- `:grad_norm` - L2 norm of gradients (when tracking enabled)
- `:grad_norm_weighted` - Weighted gradient norm: `weight * grad_norm`
- `:custom` - Custom metrics returned by the regularizer function

## Examples

    %RegularizerOutput{
      name: "l1_sparsity",
      value: 22.4,
      weight: 0.01,
      contribution: 0.224,
      grad_norm: 7.48,
      grad_norm_weighted: 0.0748,
      custom: %{"l1_total" => 44.8, "l1_mean" => 22.4}
    }

# `t`

```elixir
@type t() :: %Tinkex.Types.RegularizerOutput{
  contribution: float(),
  custom: %{required(String.t()) =&gt; number()},
  grad_norm: float() | nil,
  grad_norm_weighted: float() | nil,
  name: String.t(),
  value: float(),
  weight: float()
}
```

# `from_computation`

```elixir
@spec from_computation(
  name :: String.t(),
  loss_value :: float(),
  weight :: float(),
  custom_metrics :: map() | nil,
  grad_norm :: float() | nil
) :: t()
```

Create a RegularizerOutput from computation results.

## Parameters

- `name` - Regularizer identifier
- `loss_value` - Raw loss value (before weighting)
- `weight` - Weight multiplier
- `custom_metrics` - Map of custom metrics (or nil)
- `grad_norm` - L2 norm of gradients (optional)

## Examples

    RegularizerOutput.from_computation("l1", 22.4, 0.01, %{"l1_mean" => 22.4}, 7.48)

---

*Consult [api-reference.md](api-reference.md) for complete listing*
