elegy/metrics/reduce_confusion_matrix.py
def call(
        self,
        y_true: jnp.ndarray,
        y_pred: jnp.ndarray,
        sample_weight: tp.Optional[jnp.ndarray] = None,
    ) -> jnp.ndarray:
        """
        Accumulates confusion matrix metrics for computing the reduction metric.

        Arguments:
            y_true: Ground truth values. shape = `[batch_size, d0, .. dN]`.

            y_pred: The predicted values. shape = `[batch_size, d0, .. dN]`.

            sample_weight: Optional weighting of each example. Defaults to 1.

        Returns:
            Array with the cummulative reduce metric.
        """

        cm_metric = hooks.get_state(
            "cm_metric",
            shape=[],
            dtype=jnp.int32,
            initializer=initializers.Constant(0),
        )

        cm_metric = reduce(
            cm_metric=cm_metric,
            y_true=y_true,
            y_pred=y_pred,
            reduction=self._reduction,
            sample_weight=sample_weight,
            dtype=self.dtype,
        )

        hooks.set_state("cm_metric", cm_metric)

        return cm_metric

        Accumulates confusion matrix metrics for computing the reduction metric.

        Arguments:
            y_true: Ground truth values. shape = `[batch_size, d0, .. dN]`.

            y_pred: The predicted values. shape = `[batch_size, d0, .. dN]`.

            sample_weight: Optional weighting of each example. Defaults to 1.

        Returns:
            Array with the cummulative reduce metric.
        
Accumulates confusion matrix metrics for computing the reduction metric.
Accumulates confusion matrix metrics for computing the reduction metric .
def call(
        self,
        y_true: jnp.ndarray,
        y_pred: jnp.ndarray,
        sample_weight: tp.Optional[jnp.ndarray] = None,
    ) -> jnp.ndarray:
        cm_metric = hooks.get_state(
            "cm_metric",
            shape=[],
            dtype=jnp.int32,
            initializer=initializers.Constant(0),
        )
        cm_metric = reduce(
            cm_metric=cm_metric,
            y_true=y_true,
            y_pred=y_pred,
            reduction=self._reduction,
            sample_weight=sample_weight,
            dtype=self.dtype,
        )
        hooks.set_state("cm_metric", cm_metric)
        return cm_metric
def call ( self , y_true : jnp . ndarray , y_pred : jnp . ndarray , sample_weight : tp . Optional [ jnp . ndarray ] = None , ) -> jnp . ndarray : cm_metric = hooks . get_state ( "cm_metric" , shape = [ ] , dtype = jnp . int32 , initializer = initializers . Constant ( 0 ) , ) cm_metric = reduce ( cm_metric = cm_metric , y_true = y_true , y_pred = y_pred , reduction = self . _reduction , sample_weight = sample_weight , dtype = self . dtype , ) hooks . set_state ( "cm_metric" , cm_metric ) return cm_metric
Accumulates confusion matrix metrics for computing the reduction metric.
Accumulates confusion matrix metrics for computing the reduction metric .
"""
        Accumulates confusion matrix metrics for computing the reduction metric.

        Arguments:
            y_true: Ground truth values. shape = `[batch_size, d0, .. dN]`.

            y_pred: The predicted values. shape = `[batch_size, d0, .. dN]`.

            sample_weight: Optional weighting of each example. Defaults to 1.

        Returns:
            Array with the cummulative reduce metric.
        """
Array with the cummulative reduce metric.
Array with the cummulative reduce metric .
self
y_true
jnp.ndarray
Ground truth values. shape = `[batch_size, d0, .. dN]`.
Ground truth values . shape = ` [ batch_size d0 .. dN ] ` .
y_pred
jnp.ndarray
The predicted values. shape = `[batch_size, d0, .. dN]`.
The predicted values . shape = ` [ batch_size d0 .. dN ] ` .
sample_weight
tp.Optional[jnp.ndarray]
Optional weighting of each example. Defaults to 1.
Optional weighting of each example . Defaults to 1 .
1