Migration guide

This page describes the changes in the 1.0 release, where a major API change occurred.

The package is now compatible wtih both scikit-learn and PyTorch, and all the attributes required to configure the OPU acquisition are determined automatically.

Performance of the OPU interface has also been improved, is now up to 3 times faster.

Migrating your code should be relatively straightforward, as many aspects of the API have been simplified.

To update your virtualenv, run the following command in a shell: /usr/local/lighton/bin/update-lighton.sh update

Changes to submodules and classes names

  • lightonml.random_projections.opu has been deleted

  • lightonml.random_projections is now lightonml.projections

  • lightonml.projections.sklearn contains the new version of the sklearn wrapper for the OPU previously in lightonml.random_projections.opu

  • lightonml.projections.torch contains the new Pytorch wrapper for the OPU

  • OPURandomMapping is now OPUMap

Parameters of the OPU wrapper


  • parameters position, roi_shape and roi_position have been deleted

  • parameter opu is now optional. If it’s not passed, an OPU object will be internally instantiated for you

  • parameter disable_pbar is now verbose_level

  • new parameter ndims: if it is 1, transform accepts a 1d vector or a batch of 1d vectors. If ndims is 2, transform accepts a 2d vector or a batch of 2d vectors.

  • new parameter packed sets whether the input data is already in bit-packed representation

  • new parameter n_2d_features is mandatory for 2d packed input to know the number of 2d features

  • new parameter simulated allows to use a simulated OPU through the wrapper by setting it to True

  • new parameter max_n_features to initialize properly a simulated OPU through the wrapper


  • takes the same parameter as the sklearn wrappers


  • Grayscale images datasets in lightonml.datasets are now returned as images and not flat arrays (e.g. 60000 x 28 x28 vs 60000 x784)

  • preprocessing module is deleted

  • utils to analyze opu output are now in lightonopu