Skip to content
forked from bjader/QSSL

Code for Quantum Self-Supervised Learning

License

Notifications You must be signed in to change notification settings

allenlin316/QSSL

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is achieved using a PyTorch implementation of SimCLR based on https://github.com/facebookresearch/moco, adapted so that the encoder consists of ResNet-18 followed by a representation network. Also, the QSSL method reference to QSSL

fingerprint image preprocessing
  • Training Architecture(adapted from QSSL)
fingerprint image preprocessing

Fingerprint Image Preprocessing

  1. Fingerprint Enhancement(Gabor Filter): Python implementation reference to author Utkarsh-Deshmukh Fingerprint-Enhancement-Python
  2. Fingerprint Canny Edge Detection

Self-supervised Training with Classical Representation Network

python train_simclr.py --gpu 0 --lr 1e-3 -b 256 -d data/ -w 8 

Optional arguments:
--gpu            gpu_id
--lr             learning rate
-b               batch_size
-d               data_dir
-w               width of representation network

Self-supervised Training with Quantum Representation Network

NOTE You must clone quantum-neural-network and add it to your sys/python path first.

python train_simclr.py -q --q_backend qasm_simulator --q_ansatz sim_circ_14_half -w 8 --classes 5 --save-batches --epochs 2

Optional arguments:
-q               Flag to use a quantum representation network
--q_backend      Qiskit backend to use (can include real quantum devices)
--q_ansatz       Variational ansatz for quantum neural network.
-w               Width of representation network, in this case the number of qubits.
--classes        Use the first N classes of the dataset
--save-batches   Save the model after each batch (rather than epoch by default)
--epochs         Number of epochs to train for (quantum training takes a long time)

The so called "ring" and "all-to-all" ansatzes used in the paper correspond to --q_anzatz sim_circ_14_half and abbas in these options respectively.

Linear Probing the Above Quantum Model

python linear_probe_simclr.py --pretrained model/selfsup/path_to_checkpoint_0000.path.tar -q --q_backend qasm_simulator --q_ansatz sim_circ_14_half -w 8 --classes 5

Optional arguments:
--pretrained     path_to_self_sup_model

Reference

Jaderberg, B., Anderson, L.W., Xie, W., Albanie, S., Kiffner, M. and Jaksch, D., 2021. Quantum Self-Supervised Learning. arXiv preprint arXiv:2103.14653.

About

Code for Quantum Self-Supervised Learning

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 61.2%
  • Python 37.5%
  • Shell 1.3%