Note

This is the documentation for the current state of the development branch of Qiskit Experiments. The documentation or APIs here can change prior to being released.

TrainableDataAction

class TrainableDataAction(validate=True)[source]

A base class for data actions that need training.

Note

The parameters of trainable nodes computed during training should be listed in the class method TrainableDataAction._default_parameters(). These parameters are initialized at construction time and serialized together with the constructor arguments. All parameters defined in TrainableDataAction._default_parameters() should be assigned a None value to indicate that the node has not been trained.

Parameter values can be updated with the set_parameters() method and refer to using the TrainableDataAction.parameters() method. This is required to correctly JSON serialize and deserialize a trainable node with parameters set during training.

Create new node.

Parameters:

validate (bool) – If set to False the DataAction will not validate its input.

Attributes

is_trained

Return False if the DataAction needs to be trained.

A node is considered trained if all its parameters are assigned, or do not have None values.

Returns:

True if the data action has been trained.

parameters

Return the parameters of the trainable node.

Methods

__call__(data)

Call the data action of this node on the data.

Parameters:

data (ndarray) – A numpy array with arbitrary dtype. If the elements are ufloat objects consisting of a nominal value and a standard error, then the error propagation is done automatically.

Returns:

The processed data.

Return type:

ndarray

set_parameters(**fields)[source]

Set parameters for training.

abstract train(data)[source]

Train a DataAction.

Certain data processing nodes, such as a SVD, require data to first train.

Parameters:

data (ndarray) – A data array for training. This is a single numpy array containing all circuit results input to the data processor DataProcessor#train() method.