qml.templates

This module provides a growing library of templates of common variational circuit architectures that can be used to easily build, evaluate, and train quantum nodes.

Embeddings

Embeddings are templates that take features and encode them into a quantum state. They can optionally be repeated, and may contain trainable parameters. Embeddings are typically used at the beginning of a circuit.

Functions

AmplitudeEmbedding(features, wires[, pad, …]) Encodes \(2^n\) features into the amplitude vector of \(n\) qubits.
AngleEmbedding(features, wires[, rotation]) Encodes \(N\) features into the rotation angles of \(n\) qubits, where \(N \leq n\).
SqueezingEmbedding(features, wires[, method, c]) Encodes \(N\) features into the squeezing amplitudes \(r \geq 0\) or phases \(\phi \in [0, 2\pi)\) of \(M\) modes, where \(N\leq M\).
BasisEmbedding(features, wires) Encodes \(n\) binary features into a basis state of \(n\) qubits.
DisplacementEmbedding(features, wires[, …]) Encodes \(N\) features into the displacement amplitudes \(r\) or phases \(\phi\) of \(M\) modes,

Layers

Layers are trainable templates that are typically repeated, using different adjustable parameters in each repetition. They implement a transformation from a quantum state to another quantum state.

Functions

StronglyEntanglingLayers(weights, wires[, …]) Layers consisting of single qubit rotations and entanglers, inspired by the circuit-centric classifier design arXiv:1804.00633.
CVNeuralNetLayers(theta_1, phi_1, varphi_1, …) A sequence of layers of a continuous-variable quantum neural network, as specified in arXiv:1806.06871.
RandomLayers(weights, wires[, ratio_imprim, …]) Layers of randomly chosen single qubit rotations and 2-qubit entangling gates, acting on randomly chosen qubits.

Subroutines

Subroutines are the most basic template, consisting of a collection of quantum operations. As opposed to layers and embeddings, subroutines do not encode features, and they have no native option to be applied repeatedly.

Functions

Interferometer(theta, phi, varphi, wires[, …]) General linear interferometer, an array of beamsplitters and phase shifters.

State preperations

State preperations are templates that prepare a given quantum state, by decomposing it into elementary operations.

Functions

BasisStatePreparation(basis_state, wires) Prepares a basis state on the given wires using a sequence of Pauli X gates.
MottonenStatePreparation(state_vector, wires) Prepares an arbitrary state on the given wires using a decomposition into gates developed by Möttönen et al.