rmse

Contents

rmse#

class braintools.fit.losses.rmse(prediction, target)#

Compute the root-mean-square error between two time series.

\[\mathrm{RMSE} = \sqrt{\frac{1}{M} \sum_{i=1}^{M} (\hat y_i - y_i)^2}.\]
Parameters:
  • prediction (Any) – Model output, e.g. of shape (n_time, n_channels).

  • target (Any) – Data of the same shape and compatible units.

Returns:

Scalar RMSE; for Quantity inputs the plain magnitude in the prediction’s unit.

Return type:

Array

Raises:
  • ValueError – If the shapes differ.

  • TypeError – If only one input carries units.

  • brainunit.UnitMismatchError – If the units have different dimensions.

See also

mse, mae, fc_rmse

Notes

The same numerics as brainmass.objectives.timeseries_rmse. Works under jax.jit and jax.vmap and is differentiable; at a perfect fit the gradient is 0 rather than nan.

Examples

>>> import jax.numpy as jnp
>>> from braintools.fit import losses
>>> x = jnp.zeros((10, 3))
>>> float(losses.rmse(x + 2., x))
2.0