kd.metrics.SingleDimension

kd.metrics.SingleDimension#

class kauldron.metrics.SingleDimension(
*,
tensor: typing.Annotated[typing.Any,
<object object at 0x7824c478ba80>] = '__KEY_REQUIRED__',
index: int | None = 0,
)[source]

Bases: kauldron.metrics.base.Metric

Returns a single chosen dimension of the tensor.

tensor

kontext.Key for the tensor to capture the value of.

Type:

Any

index

Dimension to index (from the last axis). If None, no indexing is performed.

Type:

int | None

tensor: Annotated[Any, <object object at 0x7824c478ba80>] = '__KEY_REQUIRED__'
index: int | None = 0
class State(
total: "Float['']",
count: "Float['']",
*,
parent: '_MetricT' = <_EMPTY_TYPE.EMPTY: 1>,
)[source]

Bases: kauldron.metrics.base_state.AverageState

merge(
other: kauldron.metrics.base_state.AverageState,
) kauldron.metrics.base_state.AverageState[source]

Returns a new state that is the accumulation of self and other.

Parameters:

other – A State whose intermediate values should be accumulated onto the values of self.

Returns:

A new State that accumulates the value from both self and other.

replace(**updates)

Returns a new object replacing the specified fields with new values.

get_state(
tensor: jaxtyping.Float[Array, '*any'] | jaxtyping.Float[ndarray, '*any'],
) kauldron.metrics.stats.SingleDimension.State[source]
empty() kauldron.metrics.base.Metric.State[source]