anml.models package

Submodules

Model Interface

An interface for models.

class Model[source]

Bases: object

Interface for models.

forward(x, *args, **kwargs)[source]

Compute an output based on the generating mechanism defined by the model.

Parameters

x (np.ndarray) – input vector

Raises

NotImplementedError – not implemented in interface

gradient(x, data)[source]

Gradient of objective function computed using complex step method. Can be overwritten in inherited classes.

Parameters
  • x (np.ndarray) – inpute vector

  • data (Data) – a :class`~anml.data.data.Data` object.

Returns

gradient vector

Return type

np.ndarray

objective(x, data)[source]

Objective function for a model.

Parameters
  • x (np.ndarray) – input vector

  • data (Data) – a :class`~anml.data.data.Data` object

Raises

NotImplementedError – not implemented in this interface.

class TrimmingCompatibleModel[source]

Bases: anml.models.interface.Model, abc.ABC

gradient(x, data)[source]

Gradient of objective function computed using complex step method. Can be overwritten in inherited classes.

Parameters
  • x (np.ndarray) – inpute vector

  • data (Data) – a :class`~anml.data.data.Data` object.

Returns

gradient vector

Return type

np.ndarray

objective(x, data, w=None)[source]

Objective function for a model. This objective function

Parameters
  • x (np.ndarray) – input vector

  • data (Data) – a :class`~anml.data.data.Data` object

  • w (An optional weights vector) –

Raises

NotImplementedError – not implemented in this interface.

Return type

float

Module contents