# qml.templates.layers.CVNeuralNetLayers¶

CVNeuralNetLayers(theta_1, phi_1, varphi_1, r, phi_r, theta_2, phi_2, varphi_2, a, phi_a, k, wires)[source]

A sequence of layers of a continuous-variable quantum neural network, as specified in arXiv:1806.06871.

The layer consists of interferometers, displacement and squeezing gates mimicking the linear transformation of a neural network in the x-basis of the quantum system, and uses a Kerr gate to introduce a ‘quantum’ nonlinearity.

The layers act on the $$M$$ modes given in wires, and include interferometers of $$K=M(M-1)/2$$ beamsplitters. The different weight parameters contain the weights for each layer. The number of layers $$L$$ is therefore derived from the first dimension of weights.

This example shows a 4-mode CVNeuralNet layer with squeezing gates $$S$$, displacement gates $$D$$ and Kerr gates $$K$$. The two big blocks are interferometers of type pennylane.templates.layers.Interferometer:

Note

The CV neural network architecture includes Kerr operations. Make sure to use a suitable device, such as the strawberryfields.fock device of the PennyLane-SF plugin.

Parameters
• theta_1 (array[float]) – length $$(L, K)$$ array of transmittivity angles for first interferometer

• phi_1 (array[float]) – length $$(L, K)$$ array of phase angles for first interferometer

• varphi_1 (array[float]) – length $$(L, M)$$ array of rotation angles to apply after first interferometer

• r (array[float]) – length $$(L, M)$$ array of squeezing amounts for Squeezing operations

• phi_r (array[float]) – length $$(L, M)$$ array of squeezing angles for Squeezing operations

• theta_2 (array[float]) – length $$(L, K)$$ array of transmittivity angles for second interferometer

• phi_2 (array[float]) – length $$(L, K)$$ array of phase angles for second interferometer

• varphi_2 (array[float]) – length $$(L, M)$$ array of rotation angles to apply after second interferometer

• a (array[float]) – length $$(L, M)$$ array of displacement magnitudes for Displacement operations

• phi_a (array[float]) – length $$(L, M)$$ array of displacement angles for Displacement operations

• k (array[float]) – length $$(L, M)$$ array of kerr parameters for Kerr operations

• wires (Iterable or Wires) – Wires that the template acts on. Accepts an iterable of numbers or strings, or a Wires object.

Raises

ValueError – if inputs do not have the correct format