lightonml.projections

lightonml.projections.sklearn

class OPUMap(n_components, opu=None, ndims=1, n_2d_features=None, packed=False, simulated=False, max_n_features=None, verbose_level=0)[source]

Bases: sklearn.base.BaseEstimator, sklearn.base.TransformerMixin

Adapter of the OPU to scikit-learn. Transform method is mapped to transform1d or transform2d of the OPU class, depending on ndims parameter at the construction.

@see lightonopu.opu.OPU

Parameters
  • n_components (int,) – dimensionality of the target projection space.

  • opu (lightonopu.opu.OPU,) – optical processing unit instance

  • ndims (int,) – number of dimensions of an input. Can be 1 or 2. if ndims is 1, transform accepts 1d vector or batch of 1d vectors. if ndims is 2, transform accepts 2d vector or batch of 2d vectors.

  • packed (bool, optional) – whether the input data is in bit-packed representation if packed is True and ndims is 2, each input vector is assumed to be a 1d array, and the “real” number of features must be provided using n_2d_features parameter defaults to False

  • n_2d_features (list(int) or tuple(int) or np.ndarray (optional)) – number of 2d features if the input is packed

  • simulated (bool, default False,) – use real or simulated OPU

  • max_n_features (int, optional) – maximum number of binary features that the OPU will transform used only if simulated=True, in order to initiate the random matrix

  • verbose_level (int, optional) – 0, 1 or 2. 0 = no messages, 1 = most messages, and 2 = messages from OPU device (very verbose).

opu

optical processing unit instance

Type

lightonopu.opu.OPU,

n_components

dimensionality of the target projection space.

Type

int,

ndims

number of dimensions of an input. Can be 1 or 2. if ndims is 1, transform accepts 1d vector or batch of 1d vectors. if ndims is 2, transform accepts 2d vector or batch of 2d vectors.

Type

int,

packed

whether the input data is in bit-packed representation if packed is True and ndims is 2, each input vector is assumed to be a 1d array, and the “real” number of features must be provided using n_2d_features parameter defaults to False

Type

bool, optional

n_2d_features

number of 2d features if the input is packed

Type

list(int) or tuple(int) or np.ndarray (optional)

simulated

use real or simulated OPU

Type

bool, default False,

max_n_features

maximum number of binary features that the OPU will transform used only if simulated=True, in order to initiate the random matrix

Type

int, optional

fit(X, y=None)[source]

Fit method has no effect

Returns

self

Return type

OPURandomMapping.

transform(X, y=None)[source]

Performs the nonlinear random projections.

@see lightonopu.opu.transform

lightonml.projections.torch

class OPUMap(n_components, opu=None, ndims=1, n_2d_features=None, packed=False, simulated=False, max_n_features=None, verbose_level=0)[source]

Bases: torch.nn.Module

Adapter of the OPU to the Pytorch interface. Forward method is mapped to transform1d, transform2d, or transform3d of the OPU class, depending on ndims parameter at the construction.

@see lightonopu.opu.OPU

Parameters
  • n_components (int,) – dimensionality of the target projection space.

  • opu (lightonopu.opu.OPU,) – optical processing unit instance

  • ndims (int,) – number of dimensions of an input. Can be 1, 2 or 3. if ndims is 1, transform accepts 1d vector or batch of 1d vectors. if ndims is 2, transform accepts 2d vector or batch of 2d vectors.

  • packed (bool, optional) – whether the input data is in bit-packed representation if packed is True and ndims is 2, each input vector is assumed to be a 1d array, and the “real” number of features must be provided using n_2d_features parameter defaults to False

  • n_2d_features (list(int) or tuple(int) or np.ndarray (optional)) – number of 2d features if the input is packed

  • simulated (bool, default False,) – use real or simulated OPU

  • max_n_features (int, optional) – maximum number of binary features that the OPU will transform used only if simulated=True, in order to initiate the random matrix

  • verbose_level (int, optional) – 0, 1 or 2. 0 = no messages, 1 = most messages, and 2 = messages from OPU device (very verbose).

opu

optical processing unit instance

Type

lightonopu.opu.OPU,

n_components

dimensionality of the target projection space.

Type

int,

ndims

number of dimensions of an input. Can be 1, 2 or 3. if ndims is 1, transform accepts 1d vector or batch of 1d vectors. if ndims is 2, transform accepts 2d vector or batch of 2d vectors.

Type

int,

packed

whether the input data is in bit-packed representation if packed is True and ndims is 2, each input vector is assumed to be a 1d array, and the “real” number of features must be provided using n_2d_features parameter defaults to False

Type

bool, optional

n_2d_features

number of 2d features if the input is packed

Type

list(int) or tuple(int) or np.ndarray (optional)

simulated

use real or simulated OPU

Type

bool, default False,

max_n_features

maximum number of binary features that the OPU will transform used only if simulated=True, in order to initiate the random matrix

Type

int, optional

forward(input)[source]

Performs the nonlinear random projections.

@see lightonopu.opu.transform