openfl.pipelines.stc_pipeline.TernaryTransformer

class openfl.pipelines.stc_pipeline.TernaryTransformer

Bases: Transformer

A transformer class to ternarize input data.

Class Attributes:

lossy (bool) – A flag indicating if the transformation is lossy.

Methods

backward

Recover data array back to the original numerical type.

forward

Ternerize data into positive mean value, negative mean value and zero value.

backward(data, metadata, **kwargs)

Recover data array back to the original numerical type.

Parameters:
  • data – an numpy array with non-zero values.

  • metadata – dictionary to contain information for recovering back to original data array.

Returns:
  • metadata – dictionary to contain information for recovering back to original data array.

  • data – an numpy array with original numerical type.

forward(data, **kwargs)

Ternerize data into positive mean value, negative mean value and zero value.

Parameters:

data – an flattened numpy array

Returns:
  • int_data – an numpy array being terneraized.

  • metadata – dictionary to store a list of meta information.