CN114372582B - Quantum automatic coding method based on machine learning framework and related device - Google Patents

Quantum automatic coding method based on machine learning framework and related device Download PDF

Info

Publication number
CN114372582B
CN114372582B CN202210280770.0A CN202210280770A CN114372582B CN 114372582 B CN114372582 B CN 114372582B CN 202210280770 A CN202210280770 A CN 202210280770A CN 114372582 B CN114372582 B CN 114372582B
Authority
CN
China
Prior art keywords
quantum
state
quantum state
automatic coding
logic gate
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202210280770.0A
Other languages
Chinese (zh)
Other versions
CN114372582A (en
Inventor
方圆
窦猛汉
李蕾
周照辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Origin Quantum Computing Technology Co Ltd
Original Assignee
Origin Quantum Computing Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Origin Quantum Computing Technology Co Ltd filed Critical Origin Quantum Computing Technology Co Ltd
Priority to CN202210280770.0A priority Critical patent/CN114372582B/en
Publication of CN114372582A publication Critical patent/CN114372582A/en
Application granted granted Critical
Publication of CN114372582B publication Critical patent/CN114372582B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N10/00Quantum computing, i.e. information processing based on quantum-mechanical phenomena
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • General Physics & Mathematics (AREA)
  • Mathematical Physics (AREA)
  • Evolutionary Computation (AREA)
  • Data Mining & Analysis (AREA)
  • Artificial Intelligence (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Computational Linguistics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Molecular Biology (AREA)
  • Computational Mathematics (AREA)
  • Condensed Matter Physics & Semiconductors (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Logic Circuits (AREA)

Abstract

The invention discloses a quantum automatic coding method and a related device based on a machine learning framework.A quantum module is called to create a quantum automatic coding circuit, the quantum automatic coding circuit is used for evolving an initial quantum state to a compressed quantum state, the deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold value, and the number of first quantum bits corresponding to the initial quantum state is larger than the number of second quantum bits corresponding to the compressed quantum state; the method comprises the steps of inputting data to be coded into the quantum automatic coding circuit as input data, operating the quantum automatic coding circuit to obtain output data represented by a compressed quantum state, achieving compression and automatic coding of quantum data, reducing the occupancy rate of a classical automatic coder on computing resources by utilizing the quantum superposition property, and improving the speed of the automatic coder.

Description

Quantum automatic coding method based on machine learning framework and related device
Technical Field
The invention belongs to the technical field of quantum computing, and particularly relates to a quantum automatic coding method based on a machine learning framework and a related device.
Background
The automatic encoder is an unsupervised neural network model, and can learn the implicit characteristics of input data, called encoding, and can reconstruct the original input data by using the learned new characteristics, called decoding. The method can be used for feature dimension reduction and feature extraction. As an unsupervised learning model, the auto-encoder may also be used to generate new data that is different from the training samples, so that the auto-encoder is a generative model.
With the increase of data to be coded, a classic automatic encoder occupies a large amount of computing resources, and the computing speed is slower and slower. The development of quantum computing has brought about an dawn to solve this problem, and if quantum computing can be combined with an automatic encoder, the data processing capability of the automatic encoder can be further improved by utilizing the efficiency of quantum computers far beyond the efficiency of classical computers. Therefore, how to implement a quantum automatic encoder is a technical problem to be solved.
Disclosure of Invention
The invention aims to provide a quantum automatic coding method and a related device based on a machine learning framework, aiming at reducing the occupancy rate of a classical automatic coder on computing resources and improving the speed of the automatic coder.
One embodiment of the invention provides a quantum automatic coding method based on a machine learning framework, wherein the machine learning framework comprises a quantum module, and the method comprises the following steps:
calling the quantum module to create a quantum automatic coding line, wherein the quantum automatic coding line is used for evolving an initial quantum state to a compressed quantum state, the deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold, and the number of first qubits corresponding to the initial quantum state is larger than the number of second qubits corresponding to the compressed quantum state;
and inputting the data to be coded into the quantum automatic coding circuit as the input data, and operating the quantum automatic coding circuit to obtain the output data expressed by the compressed quantum state.
Optionally, the quantum module includes a quantum state evolution logic gate unit, and the invoking the quantum module to create the quantum automatic encoding circuit includes:
and calling the quantum state evolution logic gate unit to obtain a single-quantum rotation logic gate and a controlled single-quantum rotation logic gate, and acting the single-quantum rotation logic gate and the controlled single-quantum rotation logic gate on the first quantum bit to obtain a quantum automatic coding circuit.
Optionally, the applying the single-quantum rotation logic gate and the controlled single-quantum rotation logic gate to the first qubit includes:
applying the single-quantum rotation logic gate to the first qubit, applying the controlled single-quantum rotation logic gate to every two of the first qubits, and applying the single-quantum rotation logic gate to the first qubit.
Optionally, the machine learning framework further includes a classical module, before the data to be encoded is input as the input data to the quantum automatic encoding line, the method further includes:
calling the quantum state evolution logic gate unit to create a SWAP test line;
and calling the classical module to optimize the quantum automatic coding line based on the SWAP test line to obtain the optimized quantum automatic coding line.
Optionally, the quantum automatic encoding circuit is further configured to evolve the initial quantum state into a garbage quantum state, where output data represented by the garbage quantum state is to-be-discarded data in the input data, the garbage quantum state corresponds to a third qubit, and the first qubit includes the second qubit and the third qubit.
Optionally, the invoking the quantum state evolution logic gate unit to create a SWAP test line includes:
calling the quantum state evolution logic gate unit to obtain an H gate and a controlled SWAP gate;
and applying the H gate to an auxiliary qubit, applying the controlled SWAP gate to the auxiliary qubit and the third qubit, and applying the H gate to the auxiliary qubit to obtain a SWAP test line.
Optionally, the classical module includes a loss function unit and an optimizer unit, and the invoking of the classical module optimizes the quantum automatic encoding line based on the SWAP test line includes:
operating the SWAP test circuit to obtain output data of the SWAP test circuit;
determining fidelity of the initial quantum state and the compressed quantum state based on output data of the SWAP test line;
calling the loss function unit to calculate a loss function based on the fidelity;
and calling the optimizer unit to optimize parameters in the quantum automatic coding circuit based on the loss function.
Yet another embodiment of the present invention provides a quantum automatic encoding apparatus based on a machine learning framework, the machine learning framework including a quantum module, the apparatus including:
the circuit creating unit is used for calling the quantum module to create a quantum automatic coding circuit, the quantum automatic coding circuit is used for evolving an initial quantum state to a compressed quantum state, the deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold, and the number of first quantum bits corresponding to the initial quantum state is larger than the number of second quantum bits corresponding to the compressed quantum state;
and the circuit operation unit is used for inputting the data to be coded into the quantum automatic coding circuit as the input data and operating the quantum automatic coding circuit to obtain the output data expressed by the compressed quantum state.
Optionally, the quantum module includes a quantum state evolution logic gate unit, and in the aspect of invoking the quantum module to create the quantum automatic coding circuit, the circuit creating unit is specifically configured to:
and calling the quantum state evolution logic gate unit to obtain a single-quantum rotation logic gate and a controlled single-quantum rotation logic gate, and acting the single-quantum rotation logic gate and the controlled single-quantum rotation logic gate on the first quantum bit to obtain a quantum automatic coding circuit.
Optionally, in the aspect that the single-quantum rotation logic gate and the controlled single-quantum rotation logic gate are applied to the first qubit, the line creation unit is specifically configured to:
applying the single-quantum rotation logic gate to the first qubit, applying the controlled single-quantum rotation logic gate to every two of the first qubits, and applying the single-quantum rotation logic gate to the first qubit.
Optionally, the machine learning framework further includes a classical module, and before the data to be encoded is input to the quantum automatic encoding line as the input data, the line creation unit is further configured to:
calling the quantum state evolution logic gate unit to create a SWAP test line;
and calling the classical module to optimize the quantum automatic coding line based on the SWAP test line to obtain the optimized quantum automatic coding line.
Optionally, the quantum automatic encoding circuit is further configured to evolve the initial quantum state to a garbage quantum state, where output data represented by the garbage quantum state is to-be-discarded data in the input data, the garbage quantum state corresponds to a third qubit, and the first qubit includes the second qubit and the third qubit.
Optionally, in the aspect of invoking the quantum state evolution logic gate unit to create a SWAP test line, the line creation unit is specifically configured to:
calling the quantum state evolution logic gate unit to obtain an H gate and a controlled SWAP gate;
and applying the H gate to an auxiliary qubit, applying the controlled SWAP gate to the auxiliary qubit and the third qubit, and applying the H gate to the auxiliary qubit to obtain a SWAP test line.
Optionally, the classical module includes a loss function unit and an optimizer unit, and in the aspect of invoking the classical module and optimizing the quantum automatic coding line based on the SWAP test line, the line creation unit is specifically configured to:
operating the SWAP test line to obtain output data of the SWAP test line;
determining fidelity of the initial quantum state and the compressed quantum state based on output data of the SWAP test line;
calling the loss function unit to calculate a loss function based on the fidelity;
and calling the optimizer unit to optimize parameters in the quantum automatic coding circuit based on the loss function.
A further embodiment of the invention provides a storage medium having a computer program stored thereon, wherein the computer program is arranged to perform the method as described in any of the above when executed.
Yet another embodiment of the invention provides an electronic device comprising a memory having a computer program stored therein and a processor configured to execute the computer program to perform the method described in any of the above.
Compared with the prior art, the method comprises the steps of creating a quantum automatic coding circuit by calling a quantum module, wherein the quantum automatic coding circuit is used for evolving an initial quantum state to a compressed quantum state, the deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold value, and the number of first qubits corresponding to the initial quantum state is larger than the number of second qubits corresponding to the compressed quantum state; the method comprises the steps of inputting data to be coded into the quantum automatic coding circuit as input data, operating the quantum automatic coding circuit to obtain output data represented by a compressed quantum state, achieving compression and automatic coding of quantum data, reducing the occupancy rate of a classical automatic coder on computing resources by utilizing the quantum superposition property, and improving the speed of the automatic coder.
Drawings
Fig. 1 is a block diagram of a hardware structure of a computer terminal of a quantum automatic encoding method based on a machine learning framework according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a quantum automatic encoding method based on a machine learning framework according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a single quantum rotary logic gate R according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an automatic quantum encoding circuit according to an embodiment of the present invention;
FIG. 5 is a schematic structural diagram of a SWAP test circuit according to an embodiment of the present invention;
FIG. 6 is a schematic structural diagram of a machine learning model including a quantum automatic encoding circuit and a SWAP test circuit according to an embodiment of the present invention;
FIG. 7 is a schematic structural diagram of another machine learning model including a quantum automatic encoding circuit and a SWAP test circuit according to an embodiment of the present invention;
fig. 8 is a schematic structural diagram of a quantum automatic encoding device based on a machine learning framework according to an embodiment of the present invention.
Detailed Description
The embodiments described below with reference to the drawings are illustrative only and should not be construed as limiting the invention.
The embodiment of the invention firstly provides a quantum automatic coding method based on a machine learning framework, and the method can be applied to electronic equipment, such as computer terminals, specifically common computers, quantum computers and the like.
This will be described in detail below by way of example as it would run on a computer terminal. Fig. 1 is a block diagram of a hardware structure of a computer terminal of a quantum automatic encoding method based on a machine learning framework according to an embodiment of the present invention. As shown in fig. 1, the computer terminal may include one or more processors 102 (only one is shown in fig. 1) (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing the quantum auto-encoding method based on the machine learning framework, and optionally may further include a transmission device 106 for communication function and an input/output device 108. It will be understood by those skilled in the art that the structure shown in fig. 1 is only an illustration and is not intended to limit the structure of the computer terminal. For example, the computer terminal may also include more or fewer components than shown in FIG. 1, or have a different configuration than shown in FIG. 1.
The memory 104 may be configured to store software programs and modules of application software, such as program instructions/modules corresponding to the quantum automatic encoding method based on the machine learning framework in the embodiment of the present invention, and the processor 102 executes various functional applications and data processing by running the software programs and modules stored in the memory 104, so as to implement the above-mentioned method. The memory 104 may include high speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include memory located remotely from the processor 102, which may be connected to a computer terminal over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The transmission device 106 is used for receiving or transmitting data via a network. Specific examples of the network described above may include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission device 106 includes a Network adapter (NIC) that can be connected to other Network devices through a base station to communicate with the internet. In one example, the transmission device 106 can be a Radio Frequency (RF) module, which is used to communicate with the internet in a wireless manner.
It should be noted that a true quantum computer is a hybrid structure, which includes two major components: one part is a classic computer which is responsible for executing classic calculation and control; the other part is quantum equipment which is responsible for running a quantum program to further realize quantum computation. The quantum program is a string of instruction sequences which can run on a quantum computer and are written by quantum languages such as Qrun languages, so that the support on the operation of a quantum logic gate is realized, and the quantum computation is finally realized. In particular, a quantum program is a sequence of instructions that operate quantum logic gates in a time sequence.
In practical applications, due to the limited development of quantum device hardware, quantum computation simulation is usually required to verify quantum algorithms, quantum applications, and the like. The quantum computing simulation is a process of realizing the simulation operation of a quantum program corresponding to a specific problem by means of a virtual framework (namely a quantum virtual machine) built by resources of a common computer. In general, it is necessary to build quantum programs for a particular problem. The quantum program referred in the embodiment of the invention is a program written in a classical language for representing quantum bits and evolution thereof, wherein the quantum bits, quantum logic gates and the like related to quantum computation are all represented by corresponding classical codes.
A quantum circuit, which is an embodiment of a quantum program and also a weighing sub-logic circuit, is the most common general quantum computation model, and represents a circuit that operates on a quantum bit under an abstract concept, and the circuit includes the quantum bit, a circuit (timeline), and various quantum logic gates, and finally, a result is often read through a quantum measurement operation.
Unlike conventional circuits that are connected by metal lines to pass either voltage or current signals, in quantum circuits, the lines can be viewed as being connected by time, i.e., the state of a qubit evolves naturally over time, in the process being operated on as indicated by the hamiltonian until a logic gate is encountered.
The quantum program refers to the total quantum circuit, wherein the total number of the quantum bits in the total quantum circuit is the same as the total number of the quantum bits of the quantum program. It can be understood that: a quantum program may consist of quantum wires, measurement operations for quantum bits in the quantum wires, registers to hold measurement results, and control flow nodes (jump instructions), and a quantum wire may contain tens to hundreds or even thousands of quantum logic gate operations. The execution process of the quantum program is a process executed for all the quantum logic gates according to a certain time sequence. It should be noted that timing is the time sequence in which the single quantum logic gate is executed.
It should be noted that in the classical calculation, the most basic unit is a bit, and the most basic control mode is a logic gate, and the purpose of the control circuit can be achieved through the combination of the logic gates. Similarly, the way qubits are handled is quantum logic gates. The quantum state can be evolved by using quantum logic gates, which are the basis for forming quantum circuits, including single-bit quantum logic gates, such as Hadamard gates (H gates, Hadamard gates), pauli-X gates (X gates), pauli-Y gates (Y gates), pauli-Z gates (Z gates), RX gates, RY gates, RZ gates, and the like; multi-bit quantum logic gates such as CNOT gates, CR gates, isswap gates, Toffoli gates, etc. Quantum logic gates are typically represented using unitary matrices, which are not only matrix-form but also an operation and transformation. The function of a general quantum logic gate on a quantum state is calculated by multiplying a unitary matrix by a matrix corresponding to a quantum state right vector.
Referring to fig. 2, fig. 2 is a schematic flowchart of a quantum automatic encoding method based on a machine learning framework provided in an embodiment of the present invention, where the machine learning framework includes a quantum module, and the method includes:
step 201: calling the quantum module to create a quantum automatic coding line, wherein the quantum automatic coding line is used for evolving an initial quantum state to a compressed quantum state, the deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold, and the number of first qubits corresponding to the initial quantum state is larger than the number of second qubits corresponding to the compressed quantum state;
step 202: and inputting the data to be coded into the quantum automatic coding circuit as the input data, and operating the quantum automatic coding circuit to obtain the output data expressed by the compressed quantum state.
The machine learning framework integrates a plurality of function sets for creating and training the machine learning model, and functions in the function sets can be conveniently called through a defined interface to realize related operations on the machine learning model. The quantum module included in the machine learning framework can be configured to create a quantum computation layer in the machine learning model, the quantum computation layer is a program module including a quantum program, and can be used for realizing quantum computation corresponding to the quantum program, and the quantum computation layer is obtained by packaging the quantum program according to a certain standard, so that the quantum computation layer is convenient to use when the machine learning model is created and trained. The quantum program is a program for realizing quantum computation, and the quantum program can be obtained by calling a quantum module to create a quantum logic gate which acts on a quantum bit in a specific sequence, and the quantum program is encapsulated to obtain a quantum computation layer. The quantum computing layer includes a quantum autoencoding circuit.
Further, prior to said invoking said quantum module to create a quantum autoencoding circuit, said method further comprises:
invoking the quantum module to create a data encoding quantum wire, the data encoding quantum wire to encode the input data to an initial quantum state.
Wherein, the data coding quantum circuit can be one of the following: ground state encoding Quantum lines, amplitude encoding Quantum lines, angle encoding Quantum lines, transient Quantum polynomial iqp (instant Quantum multinomial) encoding lines.
Specifically, the ground state corresponds to a basis vector relative to an arbitrary quantum state. For example, for quantum states
Figure 309506DEST_PATH_IMAGE001
Wherein
Figure 83427DEST_PATH_IMAGE002
And
Figure 948615DEST_PATH_IMAGE003
in the ground state, for the quantum state
Figure 897591DEST_PATH_IMAGE004
Wherein
Figure 481020DEST_PATH_IMAGE005
Is in the ground state. Ground state encoding quantum wires are used to encode input data into a ground state among the quantum states of a quantum bit. For example, for input data 5, its binary code is 101, which in turn can be encoded into the ground state of the quantum states of the qubit
Figure 730735DEST_PATH_IMAGE006
In particular with respect to amountsSub-states
Figure 778326DEST_PATH_IMAGE007
Wherein a and b are amplitudes; for quantum state
Figure 88084DEST_PATH_IMAGE004
Wherein c, d, e, f are amplitudes. For example, for input data [1,3 ]]After normalization, 1 corresponds to 0.25, 3 corresponds to 0.75, and the quantum state can be further adjusted
Figure 158809DEST_PATH_IMAGE007
Of amplitude of
Figure 25265DEST_PATH_IMAGE008
To encode it.
Specifically, the angle encoding quantum circuit includes a sub-logic gate including parameters, for example, any one of an RX rotation gate, a RY rotation gate, and an RZ rotation gate. And performing inverse trigonometric function transformation on the input data, and using the angle obtained by the transformation as a rotation angle parameter of the revolving door, thereby realizing the encoding of the input data.
Specifically, the IQP encoding refers to obtaining an IQP encoding line by creating a logic gate of the IQP encoding line, which can encode input data x to a quantum state by operating the IQP encoding line, and using the input data as a parameter of the IQP encoding line
Figure 865045DEST_PATH_IMAGE009
Where x is tensor data, H is the H gate, n is the number of designated qubits,
Figure 345704DEST_PATH_IMAGE010
indicating that the initial quantum states of the n designated qubits are all
Figure 700462DEST_PATH_IMAGE011
And r represents
Figure 557560DEST_PATH_IMAGE012
The number of repetitions of (a) is,
Figure 251846DEST_PATH_IMAGE013
the following were used:
Figure 716457DEST_PATH_IMAGE014
wherein, the first and the second end of the pipe are connected with each other,
Figure 761773DEST_PATH_IMAGE015
the representation RZZ of the door is shown,
Figure 156983DEST_PATH_IMAGE016
denotes an RZ gate, S denotes
Figure 768093DEST_PATH_IMAGE017
A collection of qubits acted on by logic gates.
Further, if the data encoding quantum line is a ground state encoding quantum line, the ground state encoding quantum line includes an X gate. Can be connected through an X gate
Figure 856134DEST_PATH_IMAGE011
Evolved into
Figure 123168DEST_PATH_IMAGE018
For example, for input data 5, which is binary 101, then an X-gate may be used for the first and third first qubits, thereby encoding input data 5 into the ground state of the quantum states of the first qubits
Figure 135117DEST_PATH_IMAGE019
The preset threshold may be preset, and the deviation between the input data represented by the initial quantum state and the output data represented by the compressed quantum state may be represented by fidelity, or may be represented by a distance, where the distance includes an euclidean distance, a manhattan distance, an included angle cosine, a chebyshev distance, a hamming distance, and the like.
Wherein the second qubit is one or several of the first qubits.
Compared with the prior art, the method comprises the steps of creating a quantum automatic coding circuit by calling a quantum module, wherein the quantum automatic coding circuit is used for evolving an initial quantum state to a compressed quantum state, the deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold value, and the number of first qubits corresponding to the initial quantum state is larger than the number of second qubits corresponding to the compressed quantum state; the method comprises the steps of inputting data to be coded into the quantum automatic coding circuit as input data, operating the quantum automatic coding circuit to obtain output data represented by a compressed quantum state, achieving compression and automatic coding of quantum data, reducing the occupancy rate of a classical automatic coder on computing resources by utilizing the quantum superposition property, and improving the speed of the automatic coder.
Optionally, the quantum module includes a quantum state evolution logic gate unit, and the invoking the quantum module to create the quantum automatic encoding circuit includes:
and calling the quantum state evolution logic gate unit to obtain a single-quantum rotation logic gate and a controlled single-quantum rotation logic gate, and acting the single-quantum rotation logic gate and the controlled single-quantum rotation logic gate on the first quantum bit to obtain a quantum automatic coding circuit.
The single quantum rotating logic gates included in the single quantum rotating logic gate and the controlled single quantum rotating logic gate can be the same or different; the single quantum rotating logic gate can be a single quantum rotating logic gate RX, RY, RZ around an x axis, a y axis or a z axis, and can also be a single quantum rotating logic gate around any rotating axis; the number of the single quantum rotary logic gates may be one or more, and is not limited herein.
For example, as shown in fig. 3, fig. 3 is a schematic structural diagram of a single quantum rotating logic gate R according to an embodiment of the present invention. The single-quantum rotary logic gate consists of two RZ gates and a RY gate, and the action sequence on the first qubit is as follows: RZ gate, RY gate, RZ gate.
Optionally, the applying the single-quantum rotation logic gate and the controlled single-quantum rotation logic gate to the first qubit includes:
applying the single-quantum rotation logic gate to the first qubit, applying the controlled single-quantum rotation logic gate to every two of the first qubits, and applying the single-quantum rotation logic gate to the first qubit.
Further, the number of the first qubits is N, the total number of the single-quantum rotation logic gates is 2N, the number of the controlled single-quantum rotation logic gates is N × (N-1), each of the first qubits corresponds to N-1 of the controlled single-quantum rotation logic gates, the controlled bits of N-1 of the controlled single-quantum rotation logic gates are the same and are the corresponding first qubits, and the control bits are different and are first qubits except the corresponding first qubits.
Further, said applying said single quantum rotation logic gate to said first qubit, applying said controlled single quantum rotation logic gate to every two of said first qubits, and applying said single quantum rotation logic gate to said first qubit comprises:
applying N of the single quantum rotation logic gates to N of the first qubits, respectively, applying N x (N-1) of the controlled single quantum rotation logic gates to every two of the first qubits, and applying N other of the single quantum rotation logic gates to N of the first qubits, the N single quantum rotation logic gates corresponding one-to-one to the N first qubits.
For example, as shown in fig. 4, fig. 4 is a schematic structural diagram of a quantum automatic coding circuit according to an embodiment of the present invention. The number of the first quantum bits is 4, the number of the single quantum rotating logic gates is 8, and the number of the controlled single quantum rotating logic gates is 12. Firstly, 4 single quantum rotary logic gates R act on 4 first qubits, then the controlled single quantum rotary logic gate with 3 control bits as the first qubit acts on 4 first qubits, then the controlled single quantum rotary logic gate with 3 control bits as the second first qubit acts on 4 first qubits, then the controlled single quantum rotary logic gate with 3 control bits as the third first qubit acts on 4 first qubits, then the controlled single quantum rotary logic gate with 3 control bits as the fourth first qubit acts on 4 first qubits, and finally the controlled single quantum rotary logic gate with 3 control bits as the first qubit acts on 4 first qubits.
Optionally, the machine learning framework further includes a classical module, and before the data to be encoded is input as the input data to the quantum automatic encoding line, the method further includes:
calling the quantum state evolution logic gate unit to create a SWAP test line;
and calling the classical module to optimize the quantum automatic coding line based on the SWAP test line to obtain the optimized quantum automatic coding line.
Optionally, the quantum automatic encoding circuit is further configured to evolve the initial quantum state to a garbage quantum state, where output data represented by the garbage quantum state is to-be-discarded data in the input data, the garbage quantum state corresponds to a third qubit, and the first qubit includes the second qubit and the third qubit.
Optionally, the invoking the quantum state evolution logic gate unit to create a SWAP test line includes:
calling the quantum state evolution logic gate unit to obtain an H gate and a controlled SWAP gate;
and applying the H gate to an auxiliary qubit, applying the controlled SWAP gate to the auxiliary qubit and the third qubit, and applying the H gate to the auxiliary qubit to obtain a SWAP test line.
As shown in fig. 5, fig. 5 is a schematic structural diagram of a SWAP test circuit according to an embodiment of the present invention. The input state is as follows:
Figure 538417DEST_PATH_IMAGE020
through the first H gate, the quantum state evolves as:
Figure 797360DEST_PATH_IMAGE021
then through the SWAP gate, the quantum state evolves as:
Figure 614006DEST_PATH_IMAGE022
through the second H gate, the quantum state evolves:
Figure 351018DEST_PATH_IMAGE023
if it is not
Figure 874403DEST_PATH_IMAGE024
Then the first qubit may be measured to obtain the quantum state of the first qubit as
Figure 131945DEST_PATH_IMAGE011
The probability of (c) is:
Figure 107991DEST_PATH_IMAGE025
thereby can judge
Figure 648694DEST_PATH_IMAGE024
And then adjusting parameters in the quantum automatic coding circuit according to the difference to obtain the optimized quantum automatic coding circuit.
By way of further example, as shown in fig. 6, fig. 6 is a schematic structural diagram of a machine learning model including a quantum automatic coding circuit and a SWAP test circuit according to an embodiment of the present invention. Auxiliary deviceThe helper qubit comprises
Figure 292165DEST_PATH_IMAGE026
Figure 689648DEST_PATH_IMAGE027
And
Figure 418570DEST_PATH_IMAGE028
the first qubit includes
Figure 497384DEST_PATH_IMAGE029
Figure 808411DEST_PATH_IMAGE030
Figure 314479DEST_PATH_IMAGE031
And
Figure 530696DEST_PATH_IMAGE032
wherein, in the step (A),
Figure 475519DEST_PATH_IMAGE031
and
Figure 828003DEST_PATH_IMAGE032
for the second qubit to be a second qubit,
Figure 770551DEST_PATH_IMAGE029
and
Figure 21535DEST_PATH_IMAGE030
is a third qubit. And coding the data to be coded to the initial quantum state represented by the first quantum bit, and then carrying out quantum self-coding circuit evolution to obtain a compressed quantum state represented by the second quantum bit and a garbage quantum state represented by the third quantum bit.
If it is
Figure 442152DEST_PATH_IMAGE026
Has a quantum state of
Figure 914721DEST_PATH_IMAGE011
Figure 762592DEST_PATH_IMAGE033
And
Figure 750139DEST_PATH_IMAGE028
in a quantum state of
Figure 974447DEST_PATH_IMAGE034
Figure 301523DEST_PATH_IMAGE029
And
Figure 398924DEST_PATH_IMAGE030
quantum state of garbage is
Figure 811450DEST_PATH_IMAGE035
Then through SWAP test line evolution to obtain
Figure 573870DEST_PATH_IMAGE036
Optionally, the classical module includes a loss function unit and an optimizer unit, and the invoking of the classical module optimizes the quantum automatic encoding line based on the SWAP test line includes:
operating the SWAP test line to obtain output data of the SWAP test line;
determining fidelity of the initial quantum state and the compressed quantum state based on output data of the SWAP test line;
calling the loss function unit to calculate a loss function based on the fidelity;
and calling the optimizer unit to optimize parameters in the quantum automatic coding circuit based on the loss function.
Specifically, the SWAP test line is operated to obtain output data of the SWAP test line, the output data is obtained by measuring the auxiliary qubit, and the output data is
Figure 817769DEST_PATH_IMAGE037
. The fidelity of the quantum state of the garbage quantum state and the auxiliary bit can be obtained by transforming the output data
Figure 273022DEST_PATH_IMAGE038
The more fidelity the initial quantum state and the compact quantum state are, the closer the garbage quantum state is
Figure 172844DEST_PATH_IMAGE011
Thus, the higher the fidelity of the quantum states of the garbage quantum states and the helper bits. It can be seen that the fidelity of the initial quantum states and the compressed quantum states is equivalent to the fidelity of the initial quantum states and the compressed quantum states.
Further, the loss function may be set to
Figure 738955DEST_PATH_IMAGE039
. Therefore, the rotation parameters in the single-quantum rotation logic gate or the controlled single-quantum rotation logic gate can be optimized through the loss function, and then the quantum automatic coding circuit is optimized.
As shown in fig. 7, fig. 7 is a schematic structural diagram of another machine learning model including a quantum automatic encoding circuit and a SWAP test circuit according to an embodiment of the present invention. The quantum autoencode circuit in fig. 7 is the same as the quantum autoencode circuit in fig. 4, the single quantum rotation logic gate in fig. 7 is the same as the single quantum rotation logic gate in fig. 3, and the single quantum rotation logic gate is the same as the single quantum rotation logic gate in the controlled single quantum rotation logic gate. For a number of first qubits of 4, the number of auxiliary qubits is 3. The SWAP test circuit is characterized in that the first H gate acts on the auxiliary quantum bit
Figure 585164DEST_PATH_IMAGE040
The first controlled SWAP gate acting on the auxiliary bit
Figure 211317DEST_PATH_IMAGE040
Figure 598436DEST_PATH_IMAGE033
And a third qubit
Figure 764975DEST_PATH_IMAGE030
The second controlled SWAP gate acts on the auxiliary bit
Figure 921150DEST_PATH_IMAGE027
Figure 718205DEST_PATH_IMAGE028
And a third qubit
Figure 140090DEST_PATH_IMAGE029
The second H-gate acting on the auxiliary qubit
Figure 313582DEST_PATH_IMAGE040
The control bit of the first controlled SWAP-gate is an auxiliary bit
Figure 324264DEST_PATH_IMAGE040
The control bit of the second controlled SWAP-gate is an auxiliary bit
Figure 354537DEST_PATH_IMAGE033
Referring to fig. 8, fig. 8 is a schematic structural diagram of a quantum automatic encoding apparatus based on a machine learning framework according to an embodiment of the present invention, where the machine learning framework includes a quantum module, and the apparatus includes:
a line creating unit 801, configured to invoke the quantum module to create a quantum automatic coding line, where the quantum automatic coding line is configured to evolve an initial quantum state to a compressed quantum state, a deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold, and a number of first qubits corresponding to the initial quantum state is greater than a number of second qubits corresponding to the compressed quantum state;
a line operating unit 802, configured to input data to be encoded to the quantum automatic encoding line as the input data, and operate the quantum automatic encoding line to obtain output data represented by the compressed quantum state.
Optionally, the quantum module includes a quantum state evolution logic gate unit, and in the aspect of invoking the quantum module to create the quantum automatic coding line, the line creation unit 801 is specifically configured to:
and calling the quantum state evolution logic gate unit to obtain a single-quantum rotation logic gate and a controlled single-quantum rotation logic gate, and acting the single-quantum rotation logic gate and the controlled single-quantum rotation logic gate on the first quantum bit to obtain a quantum automatic coding circuit.
Optionally, in terms of applying the single-quantum rotation logic gate and the controlled single-quantum rotation logic gate to the first qubit, the line creation unit 801 is specifically configured to:
applying the single-quantum rotation logic gate to the first qubit, applying the controlled single-quantum rotation logic gate to every two of the first qubits, and applying the single-quantum rotation logic gate to the first qubit.
Optionally, the machine learning framework further includes a classical module, and before the data to be encoded is input as the input data to the quantum automatic encoding line, the line creating unit 801 is further configured to:
calling the quantum state evolution logic gate unit to create a SWAP test line;
and calling the classical module to optimize the quantum automatic coding line based on the SWAP test line to obtain the optimized quantum automatic coding line.
Optionally, the quantum automatic encoding circuit is further configured to evolve the initial quantum state to a garbage quantum state, where output data represented by the garbage quantum state is to-be-discarded data in the input data, the garbage quantum state corresponds to a third qubit, and the first qubit includes the second qubit and the third qubit.
Optionally, in the aspect of invoking the quantum state evolution logic gate unit to create a SWAP test line, the line creating unit 801 is specifically configured to:
calling the quantum state evolution logic gate unit to obtain an H gate and a controlled SWAP gate;
and applying the H gate to an auxiliary qubit, applying the controlled SWAP gate to the auxiliary qubit and the third qubit, and applying the H gate to the auxiliary qubit to obtain a SWAP test line.
Optionally, the classical module includes a loss function unit and an optimizer unit, and in terms of invoking the classical module to optimize the quantum automatic coding line based on the SWAP test line, the line creation unit 801 is specifically configured to:
operating the SWAP test line to obtain output data of the SWAP test line;
determining fidelity of the initial quantum state and the compressed quantum state based on output data of the SWAP test line;
calling the loss function unit to calculate a loss function based on the fidelity;
and calling the optimizer unit to optimize parameters in the quantum automatic coding circuit based on the loss function.
Compared with the prior art, the method comprises the steps of creating a quantum automatic coding circuit by calling a quantum module, wherein the quantum automatic coding circuit is used for evolving an initial quantum state to a compressed quantum state, the deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold value, and the number of first qubits corresponding to the initial quantum state is larger than the number of second qubits corresponding to the compressed quantum state; the method comprises the steps of inputting data to be coded into the quantum automatic coding line as input data, operating the quantum automatic coding line to obtain output data expressed by a compressed quantum state, achieving compression and automatic coding of quantum data, simultaneously utilizing the quantum superposition property, reducing the occupancy rate of a classical automatic coder to computing resources, and improving the speed of the automatic coder.
An embodiment of the present invention further provides a storage medium, in which a computer program is stored, where the computer program is configured to execute the steps in any of the above method embodiments when running.
Specifically, in the present embodiment, the storage medium may be configured to store a computer program for executing the steps of:
calling the quantum module to create a quantum automatic coding line, wherein the quantum automatic coding line is used for evolving an initial quantum state to a compressed quantum state, the deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold, and the number of first qubits corresponding to the initial quantum state is larger than the number of second qubits corresponding to the compressed quantum state;
and inputting the data to be coded into the quantum automatic coding circuit as the input data, and operating the quantum automatic coding circuit to obtain the output data expressed by the compressed quantum state.
Specifically, in this embodiment, the storage medium may include, but is not limited to: various media capable of storing computer programs, such as a usb disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic disk, or an optical disk.
Yet another embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the computer program to perform the steps in any one of the above method embodiments.
Specifically, the electronic apparatus may further include a transmission device and an input/output device, wherein the transmission device is connected to the processor, and the input/output device is connected to the processor.
Specifically, in this embodiment, the processor may be configured to execute the following steps by a computer program:
calling the quantum module to create a quantum automatic coding line, wherein the quantum automatic coding line is used for evolving an initial quantum state to a compressed quantum state, the deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold, and the number of first qubits corresponding to the initial quantum state is larger than the number of second qubits corresponding to the compressed quantum state;
and inputting the data to be coded into the quantum automatic coding circuit as the input data, and operating the quantum automatic coding circuit to obtain the output data expressed by the compressed quantum state.
The construction, features and functions of the present invention are described in detail in the embodiments illustrated in the drawings, which are only preferred embodiments of the present invention, but the present invention is not limited by the drawings, and all equivalent embodiments modified or changed according to the idea of the present invention should fall within the protection scope of the present invention without departing from the spirit of the present invention covered by the description and the drawings.

Claims (9)

1. A quantum automatic encoding method based on a machine learning framework, wherein the machine learning framework comprises a quantum module, the method comprising:
calling the quantum module to create a quantum automatic coding line, wherein the quantum automatic coding line is used for evolving an initial quantum state to a compressed quantum state and a garbage quantum state, a deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold, the number of first qubits corresponding to the initial quantum state is larger than the number of second qubits corresponding to the compressed quantum state, the output data represented by the garbage quantum state is to-be-discarded data in the input data, the garbage quantum state corresponds to a third qubit, and the first qubits include the second qubits and the third qubits;
and inputting the data to be coded into the quantum automatic coding circuit as the input data, and operating the quantum automatic coding circuit to obtain the output data expressed by the compressed quantum state.
2. The method of claim 1, wherein the quantum module includes a quantum state evolution logic gate unit, and wherein invoking the quantum module to create a quantum autoencoder circuit comprises:
and calling the quantum state evolution logic gate unit to obtain a single-quantum rotation logic gate and a controlled single-quantum rotation logic gate, and acting the single-quantum rotation logic gate and the controlled single-quantum rotation logic gate on the first quantum bit to obtain a quantum automatic coding circuit.
3. The method of claim 2, wherein the number of first qubits is N, the number of single-quantum rotation logic gates is 2N, the number of controlled single-quantum rotation logic gates is nx (N-1); said acting the single quantum rotation logic gate and the controlled single quantum rotation logic gate on the first qubit includes:
applying N of the single quantum rotation logic gates to N of the first qubits, respectively, applying N (N-1) of the controlled single quantum rotation logic gates to every two of the first qubits, and applying N of the other single quantum rotation logic gates to N of the first qubits, respectively.
4. The method of claim 2 or 3, wherein the machine learning framework further comprises a classical module, the method further comprising, before inputting the data to be encoded as the input data to the quantum automatic encoding line:
calling the quantum state evolution logic gate unit to create a SWAP test line;
and calling the classical module to optimize the quantum automatic coding line based on the SWAP test line to obtain the optimized quantum automatic coding line.
5. The method of claim 4, wherein said invoking said quantum state evolution logic gate unit to create a SWAP test line comprises:
calling the quantum state evolution logic gate unit to obtain an H gate and a controlled SWAP gate;
and applying the H gate to an auxiliary qubit, applying the controlled SWAP gate to the auxiliary qubit and the third qubit, and applying the H gate to the auxiliary qubit to obtain a SWAP test line.
6. The method of claim 4, wherein the classical module comprises a loss function unit and an optimizer unit, and the invoking the classical module optimizes the quantum auto-encoding line based on the SWAP test line comprises:
operating the SWAP test circuit to obtain output data of the SWAP test circuit;
determining fidelity of the initial quantum state and the compressed quantum state based on output data of the SWAP test line;
calling the loss function unit to calculate a loss function based on the fidelity;
and calling the optimizer unit to optimize parameters in the quantum automatic coding circuit based on the loss function.
7. An apparatus for quantum automatic encoding based on a machine learning framework, the machine learning framework comprising a quantum module, the apparatus comprising:
a circuit creating unit, configured to invoke the quantum module to create a quantum automatic coding circuit, where the quantum automatic coding circuit is configured to evolve an initial quantum state to a compressed quantum state and a garbage quantum state, a deviation between input data represented by the initial quantum state and output data represented by the compressed quantum state is smaller than a preset threshold, a number of first qubits corresponding to the initial quantum state is greater than a number of second qubits corresponding to the compressed quantum state, the output data represented by the garbage quantum state is to-be-discarded data in the input data, the garbage quantum state corresponds to a third qubit, and the first qubit includes the second qubit and the third qubit;
and the circuit operation unit is used for inputting the data to be coded into the quantum automatic coding circuit as the input data and operating the quantum automatic coding circuit to obtain the output data expressed by the compressed quantum state.
8. A storage medium, in which a computer program is stored, wherein the computer program is arranged to perform the method of any of claims 1 to 6 when executed.
9. An electronic device comprising a memory and a processor, wherein the memory has stored therein a computer program, and wherein the processor is arranged to execute the computer program to perform the method of any of claims 1 to 6.
CN202210280770.0A 2022-03-22 2022-03-22 Quantum automatic coding method based on machine learning framework and related device Active CN114372582B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210280770.0A CN114372582B (en) 2022-03-22 2022-03-22 Quantum automatic coding method based on machine learning framework and related device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210280770.0A CN114372582B (en) 2022-03-22 2022-03-22 Quantum automatic coding method based on machine learning framework and related device

Publications (2)

Publication Number Publication Date
CN114372582A CN114372582A (en) 2022-04-19
CN114372582B true CN114372582B (en) 2022-06-21

Family

ID=81146493

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210280770.0A Active CN114372582B (en) 2022-03-22 2022-03-22 Quantum automatic coding method based on machine learning framework and related device

Country Status (1)

Country Link
CN (1) CN114372582B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004289817A (en) * 2003-03-05 2004-10-14 National Institute Of Information & Communication Technology Quantum information source coding device and quantum information communication system
CN110929873A (en) * 2019-12-11 2020-03-27 合肥本源量子计算科技有限责任公司 Quantum program processing method and device, storage medium and electronic device
WO2020255076A1 (en) * 2019-06-19 2020-12-24 1Qb Information Technologies Inc. Method and system for mapping a dataset from a hilbert space of a given dimension to a hilbert space of a different dimension
CN112633507A (en) * 2020-11-27 2021-04-09 合肥本源量子计算科技有限责任公司 Method and device for encoding complex vector to quantum circuit

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030093451A1 (en) * 2001-09-21 2003-05-15 International Business Machines Corporation Reversible arithmetic coding for quantum data compression
EP3619655A1 (en) * 2017-06-02 2020-03-11 Google LLC Quantum neural network
WO2020010147A1 (en) * 2018-07-02 2020-01-09 Zapata Computing, Inc. Compressed unsupervised quantum state preparation with quantum autoencoders

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2004289817A (en) * 2003-03-05 2004-10-14 National Institute Of Information & Communication Technology Quantum information source coding device and quantum information communication system
WO2020255076A1 (en) * 2019-06-19 2020-12-24 1Qb Information Technologies Inc. Method and system for mapping a dataset from a hilbert space of a given dimension to a hilbert space of a different dimension
CN110929873A (en) * 2019-12-11 2020-03-27 合肥本源量子计算科技有限责任公司 Quantum program processing method and device, storage medium and electronic device
CN112633507A (en) * 2020-11-27 2021-04-09 合肥本源量子计算科技有限责任公司 Method and device for encoding complex vector to quantum circuit

Also Published As

Publication number Publication date
CN114372582A (en) 2022-04-19

Similar Documents

Publication Publication Date Title
CN112232513B (en) Quantum state preparation method and device
CN112633508B (en) Quantum circuit generation method and device, storage medium and electronic device
CN112633507B (en) Method and device for encoding complex vector to quantum circuit
CN114358319B (en) Machine learning framework-based classification method and related device
CN114358295B (en) Machine learning framework-based classification method and related device
CN114358216B (en) Quantum clustering method based on machine learning framework and related device
CN114358318B (en) Machine learning framework-based classification method and related device
CN113222153B (en) Quantum state simulation method and device, storage medium and electronic device
CN114358317B (en) Data classification method based on machine learning framework and related equipment
CN115293254A (en) Quantum multilayer perceptron-based classification method and related equipment
CN115311515A (en) Training method for generating countermeasure network by mixed quantum classical and related equipment
CN113222161A (en) Method and device for realizing user-defined quantum logic gate
CN114764620A (en) Quantum convolution manipulator
CN114764619A (en) Convolution operation method and device based on quantum circuit
CN113222151B (en) Quantum state transformation method and device
CN116431807B (en) Text classification method and device, storage medium and electronic device
CN114372582B (en) Quantum automatic coding method based on machine learning framework and related device
CN115346080B (en) Quantum computation-based image processing method and related equipment
CN113222157A (en) Quantum simulation method and device, electronic device and storage medium
CN114819163B (en) Training method and device for quantum generation countermeasure network, medium and electronic device
CN115809707B (en) Quantum comparison operation method, device, electronic device and basic arithmetic component
CN114372584B (en) Transfer learning method based on machine learning framework and related device
CN114764618B (en) Quantum preprocessing method and device for linear system
CN116167407B (en) Quantum circulation neural network-based data prediction method and related equipment
CN116740343B (en) Image segmentation method and device based on quantum classical mixed neural network

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant