Quantum Neural Machine Learning: Theory and Experiments DOI: http://dx.doi.org/10.5772/intechopen.84149


Table 1.

Now, the second step for the third brain region results from the activation of the

<sup>k</sup>¼<sup>1</sup> ð Þ 1 � sk 1

<sup>k</sup> ⊕ rk � � � � � sk <sup>⊕</sup> <sup>s</sup><sup>∗</sup>

> <sup>k</sup> ⊕ sk � � �

� ⊗ rk ⊕ s<sup>∗</sup>

2d

Since we have the Boolean equality p ⊕ ð Þ¼ q ⊕ p q, this means that the above density can be simplified, so that the neural field's probe and response dynamics for

> <sup>k</sup>¼<sup>1</sup> <sup>s</sup><sup>∗</sup> <sup>k</sup> ⊕ rk �

The third brain region's computation takes advantage of the entangled dynamics between the first and second brain regions to learn the optimal action. For the final density, while the first and second brain regions exhibit an entangled probe and response dynamics, the third brain region is always projecting over the optimum. It is important to stress how QNRL takes advantage of quantum entanglement such that the neural field for the third brain region followed each alternative action and then the reward processing dynamics to find the optimum in all these alterna-

!

� � �

� � <sup>s</sup><sup>∗</sup>

2d

^ <sup>þ</sup> skσ^<sup>1</sup>

� � (39)

<sup>k</sup> ⊕ sk � � ��

<sup>⊗</sup> <sup>s</sup><sup>∗</sup> j i <sup>s</sup><sup>∗</sup> h j (41)

(40)

synaptic links with the second brain region, leading to the conditional unitary

<sup>⊗</sup> j i<sup>s</sup> h j <sup>s</sup> <sup>⊗</sup> <sup>d</sup>

<sup>k</sup> ⊕ sk � �

j i<sup>r</sup> h j <sup>s</sup> <sup>⊗</sup> <sup>d</sup>

tive paths, so that the optimal action is always followed by the agent.

device shown in Table 1, for 8192 repeated experiments.

As an example of the above problem, let us consider the case where we the reward set is Ω ¼ �f g 1; 1 , and that there are two possible actions 0 and 1 leading, respectively, to the classical probability measures P<sup>0</sup> and P1, with P0½ �¼ w ¼ 1 0:4 and P1½ �¼ w ¼ 1 0:6; then, we get the probabilities of selection for each gamble and

As expected, the QASM simulator always selects the action 1, which is the best performing action by the conditional expected payoff criterion. The Tenerife device selects the correct action with a proportion of 0.778, while the Melbourne device selects the correct action with a proportion of 0.647. If, instead of the above gamble profile, we had P0½ �¼ w ¼ 1 0:6 and P1½ �¼ w ¼ 1 0:4, the optimal choice would be the action 0; in this case, as shown in Table 2, the QASM simulator, again, selects the correct action each time. The Tenerife device, in turn, selects the correct action

In Figure 5, we show the Melbourne device's results<sup>4</sup> when we have four actions

P01½ �¼ w ¼ 1 0:4, P10½ �¼ w ¼ 1 0:8, and P11½ �¼ w ¼ 1 0:9, still setting the rewards to

In this case, if we run the experiment on the QASM backend, with 8192 shots, we get the action encoded by the string 11 with relative frequency equal to 1, which

<sup>4</sup> We can only use the Melbourne device since the Tenerife device does not have the required capacity in

with a 0.857 frequency and the Melbourne device with a 0.814 frequency.

for the same rewards profile, and the probabilities are P00½ �¼ w ¼ 1 0:6,

<sup>U</sup>^ <sup>4</sup> <sup>¼</sup> <sup>∑</sup> s∈ A<sup>d</sup> 2 ^1 ⊗ d

<sup>k</sup>¼<sup>1</sup> <sup>s</sup><sup>∗</sup>

<sup>k</sup> ⊕ rk �

the third brain region projects over the optimal action:

¼ ∑ r, s∈ <sup>A</sup><sup>d</sup> 2

� � <sup>s</sup><sup>∗</sup>

Under this operator, we get the final density:

Artificial Intelligence - Applications in Medicine and Biology

operator:

<sup>ρ</sup>^<sup>4</sup> <sup>¼</sup> <sup>U</sup>^ <sup>4</sup>ρ^3U^ <sup>4</sup>

¼ ∑ <sup>r</sup>, <sup>s</sup><sup>∈</sup> A<sup>d</sup> 2

Ω ¼ �f g 1; 1 .

112

terms of number of quantum registers.

† ¼

<sup>ρ</sup>^<sup>4</sup> <sup>¼</sup> <sup>U</sup>^ <sup>4</sup>ρ^3U^ <sup>4</sup>

†

j i<sup>r</sup> h j <sup>s</sup> <sup>⊗</sup> <sup>d</sup>

Results for two alternative actions using the QASM simulator, the Tenerife device (ibmqx4) and the Melbourne device (ibmq\_16\_melbourne); in each case, 8192 shots were used, with P0½ �¼ w ¼ 1 0:4 and P1½ �¼ w ¼ 1 0:6.


Table 2.

Results for two actions using the QASM simulator, the Tenerife device (ibmqx4) and the Melbourne device (ibmq\_16\_melbourne); in each case, 8192 shots were used, with P0½ �¼ w ¼ 1 0:6 and P1½ �¼ w ¼ 1 0:4.

#### Figure 5.

Results for four actions using the Melbourne device ("ibmq\_16\_melbourne"), with 8192 shots used, and probability profiles given by: P00½ �¼ w ¼ 1 0:6, P01½ �¼ w ¼ 1 0:4, P10½ �¼ w ¼ 1 0:8 and P11½ �¼ w ¼ 1 0:9.

is the optimal action. If we run the experiment with the same number of shots on the Melbourne device, then, as shown in Figure 5, the output 11 is still the dominant action, however, with a proportion of 0.370, the second dominant action being nonresidual and with a value of 0.309 occurs for the output 10.

Therefore, the first qubit tends to be measured with the right pattern with a proportion of 0.679 (0.309 + 0.370); the probability of the second qubit being correct given that the first is correct is only about 0.54492 (0.370/0.679). This suggests that the deviation may be due to the entanglement with the environment significantly deviating the second qubit from the correct pattern.

The above algorithm was implemented using Qiskit and Python's Object Oriented Programming (OOP); the code, shown in the appendix, exemplifies how OOP can be integrated with quantum computation for implementing quantum AI on any terminal, due to the cloud access to IBM's quantum resources, constituting an example of Quantum Object Oriented Programming (QOOP) using Qiskit.

The code defines the class "Agent" with an attribute that is the quantum neural network; in this case, the attribute will be assigned a quantum circuit with the required quantum and classical registers.

measurement for the decision module, executing the algorithm on the backend (taking advantage of the cloud access) and plotting the histogram to extract the main experimental relative frequencies obtained from the repeated experiments

Cloud-based access to quantum computers opens up a major point: the empirical testing of algorithms and the implementation of computer programs in a quantum

The IBM Q Experience constitutes an example of how a programmer can use Python programming language and IBM's Python Qiskit package for building programs that use quantum computation, limited only by the specific device resources,

For quantum AI and machine learning, this provides a way to effectively bring the algorithms from the theoretical level to the test level, allowing one to test drive different quantum AI frameworks on actual quantum computers. The work developed in the previous sections allowed us to provide several examples of such an

• We showed how one can address IBM's superconducting transmon devices as examples of QUANNs, since, just as in a QUANN, the devices can only implement the conditional gates depending on the network topology and the directions of the links, which only allow for specific conditional gates to be implemented; as an example, the Tenerife device is a bowtie feedforward network, we cannot turn it into a recurrent network so that the gates have to be implemented following specific directions of the links (this limit can be experienced by any user that accesses the online resources and tries to visually

• We exemplified how basic Boolean functions' representation, in this case the XOR function, can be implemented on a (physical) quantum computer using the cloud access to Tenerife and Melbourne devices and compared the experimental results with the theoretical derivation; a relevant point of this is that we only needed three quantum registers and no hidden layer to solve the XOR problem, a point already raised about this function and generalized to other functions in [4], regarding the theoretical efficiency of QUANNs.

• We addressed how a form of quantum adaptive computation, incorporating a reward-seeking behavior and a variant of QNRL, can be implemented, in the

The three main points above help strengthen two core arguments: the first is that quantum machine learning can now be tested on actual quantum computers, making it feasible to empirically test the algorithms; the second is that, in the near future, with further advancements in quantum computation and quantum hardware, quantum adaptive computation may be implemented on actual robots with a quantum cognitive architecture that is based on cloud access to a quantum computer.

The present work addresses both core arguments by exemplifying how a form of QNRL can be employed to implement quantum adaptive computation on a physical QUANN with cloud-based access, employing QOOP and addressing, experimen-

context of quantum robotics and AI, on different quantum devices.

(the number of shots).

computational substrate has become feasible.

namely the number of quantum registers available.

Quantum Neural Machine Learning: Theory and Experiments

DOI: http://dx.doi.org/10.5772/intechopen.84149

implementation, with a few main points standing out:

build circuits in IBM Q Experience homepage).

tally, a decision under risk problem.

115

4. Conclusions

There are two methods that any instance of the class Agent must be able to implement: the first method manages the cloud access to IBM's resources, the second method implements the action selection and the quantum algorithm.

The inputs for the first method are the accounts to be loaded, for the classical computer to be able to access quantum computer via the cloud service, and the backend code, which, by default, is set to the QASM simulator but can be changed to any of the devices. The method returns the backend to be used.

The second method, for the action selection, has a structure that is specific to the problem in question; that is, the agent is offered a set of rewards and probabilities associated with each alternative action, and must choose the action that maximizes the conditional expected reward.

Thus, the probabilities are known to the agent and form part of the gamble that is offered to it; therefore, we are dealing with a decision problem under risk, and wish to address how the agent's QUANN can exhibit an adaptive computation with respect to this problem.

While, in the above equations, the adaptive nature of the quantum neural circuit was introduced in the unitary operator's parameters themselves, the Python code for the method must use the gamble's inputs to make the quantum circuit adaptive; that is, the method must be such that the agent designs its own cognitive architecture (updating its qnnet attribute) and quantum circuit using the inputs to the method, and, then, the agent must implement the cloud-based access to run, in IBM's quantum computers, the corresponding quantum algorithm.

The inputs for the method are, then, given by a list of probability distributions, where each line corresponds to a different probability gamble profile associated with each action, for instance, in the case of Table 1, the distributions are given by ([0.6, 0.4],[0.4, 0.6]). In the case of Tables 1 and 2 and Figure 5, the rewards list is [1, 1].

The other two inputs for the method are the backend used which allows the agent that is instantiated in a classical computer to access via cloud the quantum computer, using the backend code (backend\_used) and repeatedly running the algorithm on the respective device for a number of shots (num\_shots).

The choose\_action method's step zero is the extraction of the expected values and of the corresponding parameters for the adaptive gates, namely, the expected values array associated with each action is extracted by the agent using the Python library NumPy's dot product applied to the distributions and rewards lists.

The number of actions and dimension d that determines the network size are extracted from the length of the expected values array; then, the parameters for the adaptive gates are extracted by applying NumPy's argmax function on the expected values array and then converting the resulting index in binary format (using NumPy's binary\_repr). Since the indexes match the lexicographic order of binary strings, the agent, thus, effectively extracts the parameters for the adaptive unitary gates.

Now, the next step is to set up the QUANN, including the three modules, the classical registers for the measurement of the final actions to be chosen and updating the agent's qnnet attribute, assigning it the corresponding Qiskit's quantum circuit object.

The last step implements the QNRL algorithm, following the inter-module links as per the main equations introduced in this section, and defines the quantum

measurement for the decision module, executing the algorithm on the backend (taking advantage of the cloud access) and plotting the histogram to extract the main experimental relative frequencies obtained from the repeated experiments (the number of shots).
