Sequential Quantum Gate Decomposer  v1.9.3
Powerful decomposition of general unitarias into one- and two-qubit gates gates
qgd_nn.py
Go to the documentation of this file.
1 
3 """
4 Created on Tue Jun 30 15:44:26 2020
5 Copyright 2020 Peter Rakyta, Ph.D.
6 
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0
12 
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18 
19 You should have received a copy of the GNU General Public License
20 along with this program. If not, see http://www.gnu.org/licenses/.
21 
22 @author: Peter Rakyta, Ph.D.
23 """
24 
25 
27 
28 
29 import numpy as np
30 from os import path
31 from squander.nn.qgd_nn_Wrapper import qgd_nn_Wrapper
32 
33 
34 
35 
37 class qgd_nn(qgd_nn_Wrapper):
38 
39 
40 
43  def __init__( self ):
44 
45  # call the constructor of the wrapper class
46  super(qgd_nn, self).__init__()
47 
48 
49 
51  def get_NN_Chanels(self, qbit_num=-1, levels=-1, samples_num=-1 ):
52 
53  # call the C wrapper function
54  if qbit_num > 0 and levels >= 0 and samples_num < 2:
55  dim_over_2 = int(pow(2, qbit_num-1))
56  samples_num = 1
57  chanels, nontrivial_adaptive_layers = super(qgd_nn, self).get_NN_Chanels( qbit_num=qbit_num, levels=levels )
58 
59  elif qbit_num > 0 and levels >= 0 and samples_num > 1:
60  dim_over_2 = int(pow(2, qbit_num-1))
61  chanels, nontrivial_adaptive_layers = super(qgd_nn, self).get_NN_Chanels( qbit_num=qbit_num, levels=levels, samples_num=samples_num )
62 
63  else:
64  print( "invalid parameters were given")
65 
66 
67  chanels = chanels.reshape( [samples_num, qbit_num, dim_over_2, dim_over_2, 4] )
68 
69  if ( not nontrivial_adaptive_layers is None ) :
70  nontrivial_adaptive_layers = nontrivial_adaptive_layers.reshape( [samples_num, -1] )
71 
72  return chanels, nontrivial_adaptive_layers
73 
74 
75 
def get_NN_Chanels(self, qbit_num=-1, levels=-1, samples_num=-1)
Wrapper function to retrieve the data chanels for the neural network.
Definition: qgd_nn.py:51
A QGD Python interface class for the decomposition of N-qubit unitaries into U3 and CNOT gates...
Definition: qgd_nn.py:37
def __init__(self)
Constructor of the class.
Definition: qgd_nn.py:43