Value Transforms

coax.value_transforms.ValueTransform

Abstract base class for value transforms.

coax.value_transforms.LogTransform

A simple invertible log-transform.


This module contains some useful value transforms. These are functions that can be used to rescale or warp the returns for more a more robust training signal, see e.g. coax.value_transforms.LogTransform.

Object Reference

class coax.value_transforms.ValueTransform(transform_func, inverse_func)[source]

Abstract base class for value transforms. See coax.value_transforms.LogTransform for a specific implementation.

property inverse_func

The inverse transformation function \(y\mapsto x=f^{-1}(y)\).

Parameters:

y (ndarray) – The values in their transformed representation.

Returns:

x (ndarray) – The values in their original representation.

property transform_func

The transformation function \(x\mapsto y=f(x)\).

Parameters:

x (ndarray) – The values in their original representation.

Returns:

y (ndarray) – The values in their transformed representation.

class coax.value_transforms.LogTransform(scale=1.0)[source]

A simple invertible log-transform.

\[x\ \mapsto\ y\ =\ \lambda\,\text{sign}(x)\, \log\left(1+\frac{|x|}{\lambda}\right)\]

with inverse:

\[y\ \mapsto\ x\ =\ \lambda\,\text{sign}(y)\, \left(\text{e}^{|y|/\lambda} - 1\right)\]

This transform logarithmically supresses large values \(|x|\gg1\) and smoothly interpolates to the identity transform for small values \(|x|\sim1\) (see figure below).

Invertible log-transform
Parameters:

scale (positive float, optional) – The scale \(\lambda>0\) of the linear-to-log cross-over. Smaller values for \(\lambda\) translate into earlier onset of the cross-over.

property inverse_func

The inverse transformation function \(y\mapsto x=f^{-1}(y)\).

Parameters:

y (ndarray) – The values in their transformed representation.

Returns:

x (ndarray) – The values in their original representation.

property transform_func

The transformation function \(x\mapsto y=f(x)\).

Parameters:

x (ndarray) – The values in their original representation.

Returns:

y (ndarray) – The values in their transformed representation.