openfl.pipelines.stc_pipeline.STCPipeline#

class openfl.pipelines.stc_pipeline.STCPipeline(p_sparsity=0.1, n_clusters=6, **kwargs)[source]#

Bases: TransformationPipeline

A pipeline class to compress data lossly using sparsity and ternarization methods.

p#

The sparsity factor.

Type:

float

__init__(p_sparsity=0.1, n_clusters=6, **kwargs)[source]#

Initialize a pipeline of transformers.

Parameters:
  • p_sparsity (float, optional) – The sparsity factor. Defaults to 0.1.

  • n_clusters (int, optional) – The number of K-mean clusters. Defaults to 6.

  • **kwargs – Additional keyword arguments for the pipeline.

Returns:

Data compression transformer pipeline object.

Methods

__init__([p_sparsity, n_clusters])

Initialize a pipeline of transformers.

backward(data, transformer_metadata, **kwargs)

Backward pass of pipeline data transformer.

forward(data, **kwargs)

Forward pass of pipeline data transformer.

is_lossy()

If any of the transformers are lossy, then the pipeline is lossy.

backward(data, transformer_metadata, **kwargs)[source]#

Backward pass of pipeline data transformer.

Parameters:
  • data – The transformed data.

  • transformer_metadata – The metadata for the transformation.

  • **kwargs – Additional keyword arguments for the transformation.

Returns:

The original data before the transformation.

forward(data, **kwargs)[source]#

Forward pass of pipeline data transformer.

Parameters:
  • data – The data to be transformed.

  • **kwargs – Additional keyword arguments for the transformation.

Returns:

The transformed data. transformer_metadata: The metadata for the transformation.

Return type:

data

is_lossy()[source]#

If any of the transformers are lossy, then the pipeline is lossy.

Returns:

True if any of the transformers in the pipeline are lossy, False

otherwise.