Quantum-Inspired Neural Network Model of Optical Illusions

Ambiguous optical illusions have been a paradigmatic object of fascination, research and inspiration in arts, psychology and video games. However, accurate computational models of perception of ambiguous figures have been elusive. In this paper, we design and train a deep neural network model to simulate the human's perception of the Necker cube, an ambiguous drawing with several alternating possible interpretations. Defining the weights of the neural network connection using a quantum generator of truly random numbers, in agreement with the emerging concepts of quantum artificial intelligence and quantum cognition we reveal that the actual perceptual state of the Necker cube is a qubit-like superposition of the two fundamental perceptual states predicted by classical theories. Our results will find applications in video games and virtual reality systems employed for training of astronauts and operators of unmanned aerial vehicles. They will also be useful for researchers working in the fields of machine learning and vision, psychology of perception and quantum-mechanical models of human mind and decision-making.


Introduction
Optical illusions have fascinated humans since the ancient times [1][2][3] and served as both object of inspiration in arts [4,5] and paradigmatic topic of research in the fields of psychology and behavioural science [6][7][8][9][10][11][12][13].Nowadays, when artificial intelligence (AI) is all around, a question arises whether a computer or robotic system can recognise optical illusions similarly to a human.Apart from a blue-skies research goal of creating a humanoid robot that both aesthetically resembles a human and can perceive the world as a human, a practicable model of human perception of optical illusions could revolutionise the way video games and spatial computing systems are designed [14], psychiatric illnesses are studied [15] and the effect of gravitation on cognition is investigated [16,17].Moreover, establishing the psychological and physiological origin of perception of ambiguous figures promises to unlock the secrets of human decision-making [9], also revealing a longhypothesised but yet elusive link between human mental states and quantum mechanics [8,9,[18][19][20][21][22][23].
Consider the Necker cube [2] shown in Figure 1a.A simple self-examination aimed to answer the question 'Is the shaded face of the cube at the front or at the rear?' will result in a series of possible interpretations that randomly switch between 'front' and 'rear'.When the sequence of the observed front-rear states, which in the following we denote as |0⟩ and |1⟩, is recorded as a function of time as schematically shown in Figure 1b, one obtains a signal consisting of rectangular pulses of random duration.The temporal dynamics of the pulses will vary from one self-examination to another since the perception of optical illusions depends on the observer's age and gender [24].However, the general trend illustrated in Figure 1b will be similar for all observers.
On the other hand, electroencephalograms recorded consistently with subjective inputs given by observers of the Necker cube and other ambiguous figures [25][26][27] suggest that the perception does not undergo an abrupt switching as sketched in Figure 1c but exhibits a rather continuous oscillation-like behaviour between the |0⟩ and |1⟩ states.Data speaking in favour of such a behaviour were also obtained in eye-tracking experiments, where both blink and movement of eye were associated with a perceptual reversal [6,28,29].These experimental results indicate that the perceptual state may not exactly be |0⟩ or |1⟩ state but their combination.Mathematically, this scenario can be described as a superposition of |0⟩ and |1⟩ [9].This intriguing observation has motivated the attempts to apply the methods of quantum mechanics and quantum computing to the analysis of human perception [9,21,30,31].
When a quantum measurement is done, a closed qubit system interacts in a controlled way with an external system from which the state of the qubit under measurement can be recovered.For example, using the projective measurement operators M 0 = |0⟩⟨0| and M 1 = |1⟩⟨1| [32], the measurement probabilities for |ψ⟩ = α|0⟩ + β|1⟩ are P |0⟩ = |α| 2 and P |1⟩ = |β| 2 , which means that the qubit will be in one of its basis states.Such a projective measurement can be visualised using the concept of the Bloch sphere where the qubit is projected on one of the coordinate axes (e.g., z-axis in Figure 2a).Computational algorithms based on measurements of the states of a qubit are exponentially faster than any possible deterministic classical algorithm [32].Subsequently, it has been demonstrated that quantum mechanics can explain certain psychological and decision-making processes better than any classical model [9,31,33].A large and growing body of research has provided significant evidence speaking in favour of this hypothesis [8,21,22,[34][35][36][37][38][39][40][41][42][43][44][45][46][47].
In Figure 2b that was rendered using the physical ray-tracing software POV-Ray, we illustrate how the principle of projective qubit measurement can be generalised to the Necker cube.The two-dimensional (bottom) images in Figure 2b are the shadows cast by the three-dimensional cubes.However, while the three-dimensional cubes are visually different, the shadows cast by them are identical.Yet, the shadows are an ambiguous Necker cube with the alternating left and right faces (this can be seen by observing them for a 5-10 seconds; some observers may also need to blink to notice the optical illusion [48]).Drawing an analogy with the projective measurement pictured in Figure 2a, in Figure 2b we consider the shadows as a qubit-like superposition of the two fundamental perceptual states of the cube and we virtually project these images back to the three-dimensional space to obtain an unambiguous (either |0⟩ or |1⟩ basis state) image of the cube.
It is noteworthy that the application of the concepts of qubit and superposition does not imply the existence of quantum processes in a biological brain.In fact, the analogy with a qubit serves as a mathematical model that can adequately describe the experimental data.At the same time, an ultimate verification of the accuracy of the quantum models is not practicable due to technical immaturity and high-cost of quantum computers and adjacent technologies.Yet, from the neurobilogical point of view, an idealised experiment would also include measurements conducted with a brain-computer interface that can decipher the human 'thoughts'.Clearly, such complex tests are not yet feasible and they also raise ethics concerns.
Subsequently, much of the current research in this area has focused on artificial neural network modelling and digital twins of perception of optical illusions [25,[49][50][51][52][53][54].Some of these works have employed experimental electroencephalogram (EEG) and magnetoencephalography (MEG) data as the signals that are processed using a neural network model and then classified and correlated with experimental perceptual states of ambiguous figures [25,[52][53][54].In turn, the works [50,51,55] have focused on the analysis of the dynamics of perception of the images of the ambiguous figures using neural network architectures that exhibit a chaotic behaviour.However, the results obtained in Ref. [51] reproduce the results obtained in classical models of bistable perception, i.e. they do not predict any superposition of the two possible perceptual states of the Necker cube (quantum-mechanical models of cognition and perception had not been widely accepted when the paper [51] was published).On the other hand, although the paper [55] does not discuss the perception of ambiguous figures, the neural network model proposed in it reveals a possibility of a superposition of two states in principle.
In this present work, we construct a deep neural network that uses a quantum random generator to define the weights of the neural connections and we exploit it to model the perception of the ambiguous figures.We demonstrate that the so-designed computational algorithm reproduces the hypothesised superposition of the possible perceptual states of the Necker cube.We also show that these results agree with the predictions of a recently proposed quantum oscillator model of optical illusions [14].

Deep Neural Network Algorithm
The architecture of the neural network used in this work is illustrated in Figure 3.The network consists of an input layer that has L = 100 input nodes, three hidden layers each of which has N = 20 nodes and an output layer that has M = 2 output nodes that are used to classify the perceptual state of the Necker cube.The weights of the connections of the network are updated using a cross entropy-driven back-propagation algorithm [56,57].The learning rate parameter used in all computations is α = 0.01.The activation function of the nodes of the hidden layers are represented by the Rectified Linear Unit (ReLU) that can be defined as [56,57] ϕ ReLU (x j ) = x, x j > 0 0, where j = 1 . . .L is the index denoting the sequential number of the input node and x j is the output from this node.As the activation function of the output nodes we choose the Softmax function that accounts not only for the weighted sum of the inputs to the given node but also for the inputs to the other output nodes [56,57].This function is where v i is the weighted sum of the input signals to the ith output node and M is the total number of the output nodes.The use of Eq. ( 2) enables satisfying the probability normalisation condition The network is trained using the following procedure [57]: Construct two output nodes that correspond to |0⟩ = [1 0] and |1⟩ = [0 1] perceptual states of the Necker cube; 2.
Initialise the weights of the neural network in the range from -1 to 1 using a random number generator; 3.
Enter the input data x j and the corresponding training data d i that encode the perceptual states of the Necker cube (the top and the middle illustrations on the left of Figure 3); 4.
Calculate the error e i between the output y i and target d i as e i = d i − y i ; 5.
Propagate the output δ i = e i in the backward direction of the network and compute the respective parameters δ of the hidden nodes using the equations e i , where the index n denotes the sequential number of the hidden layer, prime denotes the derivative of the activation function and W ⊤ is the transpose of the matrix of weights corresponding to each relevant layer of the network.6.
Repeat Step 5 until the back-propagation algorithm reaches the first hidden layer; 7.
Update the weights using the learning rule w , where w (n) ij are the weights between an output node i and input node j of the nth layer and ∆w Repeat Steps 4-7 for all values of the training data set.9.
Repeat Steps 4-8 until the neural network is trained with a desired accuracy.
The exploitation process essentially reproduces Steps 1-3 [57].We established that it suffices to use 1000 epochs to obtain convergent results in all calculations.
The physical processes underpinning the dynamics of switching between the perceptual states of ambiguous figures remains a subject of debate [7,58].One of the currently accepted theories suggests that the switching is likely to be explained by chaotic processes observed in nonlinear dynamical systems [51,55,[59][60][61].Indeed, broadly speaking, the brain is a dynamical system that that exhibits a complex nonlinear and chaotic behaviour at multiple levels [62][63][64].Subsequently, it is plausible that certain highly nonlinear and chaotic physical system can approximate the behaviour of a brain at least in principle [65].
To implement a chaotic dynamical behaviour in our model, we employ a quantumphysical generator of random numbers [66,67] to define the matrices W (n) that contain the weights of the connections of the neural network.Unlike the output of a pseudo-random generator such as the one described in Ref. [68], a quantum generator produces truly random numbers [66,67].In our model, this property implies that the neural network is not biased towards one of the possible perceptual states of the Necker cube and that its predictions do not repeat in time [69,70].Furthermore, as with the purely classical neural network models [51,55], our quantum random generator based neural network exhibits a truly chaotic dynamical behaviour [71] and, therefore, can be considered to be a chaos-driven system [51,55].
As illustrated in Figure 4, we first randomly generate W (n) , then we train the network on the data corresponding to the Necker cubes with the shaded faces and then we exploit the trained neural network to predict the perceptual state of the ambiguous Necker cube.This procedure is repeated in a loop to plot the perceived states of the cube as a function of time.

Results: Predictions of the Neural Network Model
Figure 5 shows the prediction by the neural network model obtained as a result of 100 consecutive runs of the algorithm outlined in Figure 4.The states of the output nodes of the neural network were recorded at end of each computational run and the respective results were plotted as a function of time (in arbitrary units).Therefore, every pair of data points that constitute the curves in Figure 5 was obtained using a unique initial set of neural weights W (n) obtained from a truly random quantum-physical system [66,67].
We can observe a time-dependent switching between the two possible classical perception states of the cube that correspond to the probability values 0 and 1 on the y-axis of Figure 5. Importantly, the pattern of the switching between one perceptual state to another is not abrupt, as often depicted in the literature and schematically shown in Figure 1b of this paper, but gradual.Thus, the data produced by the neural network model speak in favour of plausibility of the previous theoretical results [9] and experimental evidence [25][26][27] demonstrating that the actual perception state is a superposition of the two fundamental states |0⟩ and |1⟩ of the Necker cube.
Similar results were obtained using a quantum oscillator model of perception of ambiguous figures.In the following section, we overview the algorithm of that model and then compare its predictions with the result shown in Figure 5.

Quantum Oscillator Model of Perception of Ambiguous Figures
We model the dynamics of perception of the Necker cube using a harmonic motion of an electron trapped in a parabolic potential well (Fig. 6a).This model is inspired by the quantum-mechanical approach to human cognition proposed in Ref. [9] and it captures the complex pattern of perception of the Necker cube [14].
A classical mechanics counterpart of this model is a small ball that rolls back and forth inside a bowl.While the ball does not have enough energy to surmount or penetrate a physical barrier inside the bowl, the electron may pass through the barrier due to the quantum tunnelling effect (Fig. 6a).
We model the quantum tunnelling effect by solving the Schrödinger equation in a one-dimensional space [72] ih ∂ψ(x, t) ∂t where ψ(x, t) is a wave function, i is the imaginary unit, m is the mass of the electron, h is Plank's constant and V(x) is the parabolic potential well profile.We numerically solve Eq. ( 3) using a finite-difference time-domain (FDTD) method [73] that represents the wave function as ψ(x, t) = ψ re (x, t) + iψ im (x, t).We obtain ) Representing the coordinate x and time t as the vectors of discrete elements x k = k∆x and t n = n∆t, respectively, where k and n are integer numbers, and applying the Courant stability criterion [73], we define Thus, a spatio-temporally discretised Eq. ( 4) becomes We model the electron as a Gaussian energy wave packet: where λ is the wavelength, σ is the width of the Gaussian pulse and k 0 is the spatial coordinate of origin of the pulse.The amplitudes of the wave functions are normalised as The probabilities of funding the electron is the |0⟩ and |1⟩ regions of the potential well are calculated as where Using the model parameters ∆x = 0.1 × 10 −11 m, λ = 1.6 × 10 −10 m and σ = 1.6 × 10 −10 m, in Figure 6b we present the results of modelling of the electron tunnelling through a potential barrier.Calculating the modulus square of the wave function, we obtain the probability density of finding the electron at a certain position in the parabolic potential well.We can see that one part of the incident wave packet is reflected from the barrier but another part is transmitted through it.We label the left and right side of the parabolic potential well as |0⟩ and |1⟩ and associate them with the possible perceptual states of the Necker cube.In this particular demonstration simulation scenario, we obtain P |0⟩ = 0.35 and P |1⟩ = 0.65.

Results: Predictions of the Quantum Oscillator Model
Figure 7 shows the results produced by the quantum oscillator model.We consider a single parabolic well (Figure 7a.i) and a double-parabolic well with a barrier formed by two overlapping parabolic wells (Figure 7b.i).Assuming that the energy packet that represents the electron originates from the left side of the potential well (this corresponds to a visual cue to the cube orientation [9]), we simulate the dynamics of the oscillator in the time interval from 0 to 200 arbitrary units (these arbitrary units are different from those used in the neural network model).The result of this simulation is plotted in Figure 7a.ii,where the probability of finding the electron in the |0⟩ and |1⟩ regions of the potential well are denoted by the solid and dotted curves, respectively.The result of the simulation of the double-parabolic well is presented in Figure 7b.ii.

Neural Network Model versus Quantum Oscillator Model
In Figure 7a.ii,we can see that the quantum oscillator model with a single potential well predicts a periodic switching between the two fundamental perceptual states, with a quick but not instantaneous change from one fundamental perceptual state to another.This result is similar to the prediction of the previous quantum-mechanical models proposed in Refs.[9,21] and it implies the existence of a superposition of the fundamental perceptual states.A qualitatively similar results is predicted by the neural network, which can be seen in Figure 5 in the time intervals from approximately T = 5 to T = 20.
Furthermore, a periodic switching between the two fundamental perceptual states predicted by the neural network model alternates with the periods of irregular switching between these states (e.g. from T = 80 to approximately T = 90 in Figure 5).This behaviour is qualitatively reproduced by the quantum oscillator model that uses the double-periodic well with the barrier (Figure 7b.ii).We note that the time units used in the quantum oscillator model are different from those used in the neural network model, which means that the timescale of alternations between the perceptual states is different in these two models.This difference is inconsequential for the current discussion and, if needed, it can be eliminated using a different profile of the parabolic potential wells.
Thus, we conclude that the quantum oscillator model can reproduce the predictions of the neural network model provided that the outputs of the single and double parabolic potential well oscillators are combined together, which can be done, for example, by coupling them into a chain oscillator.While the discussion of an implementation of this approach is beyond the scope of this paper, the similarity of the outputs of the neural network model and the quantum oscillator model has a clear physical meaning: both models are dynamical systems that operate according to the fundamental laws of quantum mechanics [74][75][76].
Moreover, the results obtained using the neural network model speak in favour of the hypothesis that originates from the quantum oscillator model and that suggests that the phase change in the response of the dynamical system has effect of eye blinking, an action known to induce a reversal of the perceptual state of the Necker cube [11,14,48].Although this hypothesis has not been verified yet, it is known that the dynamics of eye blinks can be studied using the methods developed to investigate highly nonlinear and chaotic processes [77][78][79].Hence, since the neural network model employs data produced by a generator of truly random numbers, its predictions should be consistent with the dynamics of the eye blink [69,80].

Potential Applications in Artificial Intelligence and Virtual Reality Systems
The proposed neural network algorithm can be used as a model of optical illusions in film-making, architecture design and game development [4,81,82].For example, the video game Superliminal uses forced perspective techniques that manipulate human visual perception to make an object appear larger or smaller than it actually is [83].The same algorithm can be used in an advanced machine vision system intended to simulate the human perception and decision-making.In particular, the so-designed machine vision system may be tasked to play a video game such as Superliminal and its actions can be compared with the actions of a human operator, providing a valuable feedback for engineers, neuroscientists and psychologists.
The neural network model of optical illusions can be used to study the impact of weightlessness on the ability of astronauts to undertake complex tasks during and after spaceflights.On Earth, the majority of observers of ambiguous figures such as the Necker cube perceive one interpretation more often than the other.However, in weightlessness, this asymmetry gradually disappeared and, after spending several months in orbit, both interpretations have the same occurrence [16,17].
The operation of unmanned aerial vehicle (UAVs), commonly known as drones, is another area where models of optical illusions may help extend the abilities of both humans and AI.For example, at present the skills of human race drones operators significantly exceed the performance of the most advanced machine vision algorithms [84].A better understanding of the ability of human pilot to select appropriate motor commands from highly dynamic visual information may provide key insights for solving current challenges in vision-based autonomous navigation.
Yet, the neural network model of optical illusions can be used to validate certain neuroscience and psychological perception theories that are complimentary to the quantum mind hypothesis [85,86].According to some mainstream theories, our subjective perception of the world is unitary coherent [87].Here, unitary means that we perceive one interpretation at a time (e.g. one of the two possible states of the Necker cube) rather than a blur of the possible interpretations (i.e.we never see the two possible states of the cube together).In turn, coherent means that we perceive scenes that do not contain contradictory parts (e.g., we do not see a part of one cube and a part of another one at the same time).
However, such an intuitive approach contradicts the theories of optimal decisionmaking and Bayesian brain [85,86].These theories suggest that an optimal decision can be made only integrating the utility of all actions while considering all possible interpretations of sensory data.
To verify these alternative theories, a video game involving two scenarios was designed [87], where the players were first trained in a visually unambiguous scenario and then they played the same game but in an optical illusion scene that involved an image of the Necker cube.The proposed neural network model can be integrated with that game to address the weaknesses of the experiment identified in Ref. [87].

Conclusions
This paper demonstrates the potential of a deep neural network algorithm powered by a quantum random number generator to simulate the human perception of optical illusions exemplified by the Necker cube.The results produced by the model indicate that observers are likely to perceive a superposition of the fundamental perceptual states of the cube.
This finding aligns with the emerging psychology theories suggesting that certain psychological phenomena can be adequately described using such quantum-mechanical concepts as qubit, superposition of states and projective measurement.In particular, we compared the results produced by the neural network with the predictions of a recently proposed quantum oscillator model of optical illusions and we established that both models consistently predict a qubit-like superposition of perceptual states.
The proposed neural network model can be used in various AI systems ranging from video games and virtual reality and metaverse products, also being a useful tool for psychological and neuroscience studies.It can also be utilised to train astronauts and operators of UAVs to perform in visually challenging environments.

Figure 1 .
Figure 1.(a) The Necker cube.The answer to the question 'Is the shaded face of the cube at the front or at the rear?' will change suddenly depending on the observer's perception, giving rise to a series of rectangular pulses corresponding to the front, |0⟩, and rear, |1⟩, perceptual states of the cube shown in panel (b).

Figure 2 .
Figure 2. (a) Projective measurement of a qubit.(b) Projective qubit-like measurement applied to the Necker cube.The two-dimensional shadows of the cubes are identical and perceived by an observer as an ambiguous Necker cube.Considering the shadows as a qubit-like superposition of |0⟩ and |1⟩, we virtually project the shadows back to the three-dimensional space to obtain an unambiguous cube that corresponds to one of the basis states.

Figure 3 .
Figure 3. Sketch of the deep neural network architecture used to model the perception of the Necker cube.The network consists of an input layer, three hidden layers and an output layer that has two nodes.The labels W (n) with n = 1 . . . 4 denote the matrices of the weights of the network connections.The network is trained using the images of the Necker cube with the shaded front and rear faces that correspond to the |0⟩ = [0 1] and |1⟩ = [1 0] training states, respectively.The characters '|0⟩' and '|1⟩' are not a part of the training images.The test input is an image of the ambiguous Necker cube.All input images consist of a total of 100 pixels.The individual pixels of each image form an input vector x j with j = 1 . . .100.

Figure 4 .
Figure 4. Sketch of the recurring computation procedure that involves the generation of the connection weights using a random generator, training of the network and its exploitation to predict the perceptual state of the Necker cube.The characters '|0⟩' and '|1⟩' are not a part of the training images.

Figure 5 .
Figure 5. Perceptual switching curves simulated by the neural network model using quantumrandom neural connection weights.The data produced by the two output nodes of the network are plotted using the solid and dotted curves, respectively.The data points with the probability P |0⟩ = 0 or P |1⟩ = 1 correspond to the fundamental perceptual states of the Necker cube.The remaining data points are in a superposition of the states |0⟩ and |1⟩ with P |0⟩ + P |1⟩ = 1.

Figure 6 .
Figure 6.(a) An electron trapped in a parabolic well behaves as a harmonic oscillator and it can pass through a barrier due to the quantum tunnelling effect.(b) Illustrative example (numerical simulation) of quantum tunnelling through a barrier.The dashed line denotes an snapshot of the incident Gaussian pulse.The solid line denotes the snapshots of the portions of the pulse that are reflected from and transmitted through the barrier (the green line, right y-axis).The labels |0⟩ and |1⟩ correspond to the perceptual states of the Necker cube.

Figure 7 .
Figure 7. (a) A single parabolic potential well model and the Necker cube perception switching predicted by it.(b) The respective double-parabolic model with a barrier and its predictions.In both panels, the labels |0⟩ and |1⟩ denote the fundamental perceptual states of the Necker cube.The time units used in this figure are different from those in Figure 5.