hqm.layers.basiclayer

 1import sys
 2
 3sys.path += ['.', './utils/', '/circuits/']
 4
 5from hqm.circuits.circuit import QuantumCircuit
 6from hqm.utils.aiinterface import AIInterface
 7
 8
 9class BasicLayer:
10    '''
11        Basic Quantum Layer
12    '''
13
14    def __init__(self, qcircuit : QuantumCircuit, aiframework : str) -> None:
15        '''
16        BasicLayer constructor.  
17
18        Parameters:  
19        -----------  
20        - qcircuit : hqm.circuits.circuit.QuantumCircuit  
21            QuantumCircuit object to be embedded into the quantum layer
22        - aiframework : str    
23            string representing the AI framework in use, can be 'torch' or 'keras'. This will create  
24            a compatible trainable layer for the framework.   
25
26        Returns:    
27        --------     
28        Nothing, a BasicLayer object will be created.  
29        '''
30        
31        if aiframework not in ['torch', 'keras']: raise Exception(f"Accepted values for framerwork are 'torch' or 'keras', found {aiframework}")
32
33        self.aiframework = aiframework
34        self.n_qubits    = qcircuit.n_qubits
35        self.qlayer      = AIInterface.network_layer(
36                                circuit      = qcircuit.circuit, 
37                                weight_shape = qcircuit.weight_shape, 
38                                n_qubits     = qcircuit.n_qubits, 
39                                aiframework  = self.aiframework
40                            )
class BasicLayer:
10class BasicLayer:
11    '''
12        Basic Quantum Layer
13    '''
14
15    def __init__(self, qcircuit : QuantumCircuit, aiframework : str) -> None:
16        '''
17        BasicLayer constructor.  
18
19        Parameters:  
20        -----------  
21        - qcircuit : hqm.circuits.circuit.QuantumCircuit  
22            QuantumCircuit object to be embedded into the quantum layer
23        - aiframework : str    
24            string representing the AI framework in use, can be 'torch' or 'keras'. This will create  
25            a compatible trainable layer for the framework.   
26
27        Returns:    
28        --------     
29        Nothing, a BasicLayer object will be created.  
30        '''
31        
32        if aiframework not in ['torch', 'keras']: raise Exception(f"Accepted values for framerwork are 'torch' or 'keras', found {aiframework}")
33
34        self.aiframework = aiframework
35        self.n_qubits    = qcircuit.n_qubits
36        self.qlayer      = AIInterface.network_layer(
37                                circuit      = qcircuit.circuit, 
38                                weight_shape = qcircuit.weight_shape, 
39                                n_qubits     = qcircuit.n_qubits, 
40                                aiframework  = self.aiframework
41                            )

Basic Quantum Layer

BasicLayer(qcircuit: hqm.circuits.circuit.QuantumCircuit, aiframework: str)
15    def __init__(self, qcircuit : QuantumCircuit, aiframework : str) -> None:
16        '''
17        BasicLayer constructor.  
18
19        Parameters:  
20        -----------  
21        - qcircuit : hqm.circuits.circuit.QuantumCircuit  
22            QuantumCircuit object to be embedded into the quantum layer
23        - aiframework : str    
24            string representing the AI framework in use, can be 'torch' or 'keras'. This will create  
25            a compatible trainable layer for the framework.   
26
27        Returns:    
28        --------     
29        Nothing, a BasicLayer object will be created.  
30        '''
31        
32        if aiframework not in ['torch', 'keras']: raise Exception(f"Accepted values for framerwork are 'torch' or 'keras', found {aiframework}")
33
34        self.aiframework = aiframework
35        self.n_qubits    = qcircuit.n_qubits
36        self.qlayer      = AIInterface.network_layer(
37                                circuit      = qcircuit.circuit, 
38                                weight_shape = qcircuit.weight_shape, 
39                                n_qubits     = qcircuit.n_qubits, 
40                                aiframework  = self.aiframework
41                            )

BasicLayer constructor.

Parameters:

  • qcircuit : hqm.circuits.circuit.QuantumCircuit
    QuantumCircuit object to be embedded into the quantum layer
  • aiframework : str
    string representing the AI framework in use, can be 'torch' or 'keras'. This will create
    a compatible trainable layer for the framework.

Returns:

Nothing, a BasicLayer object will be created.