Hi, I have been tring to make hybrid quantum-classical model.
I have two questions about that.
- classical layer between quantum layers
: First, I attempted hybrid layer codes as follows.
dev = qml.device(‘default.qubit’, wires = 8)
@qml.qnode(dev)
def QCNN (…):
embedding.data_embedding(X, embedding_type=embedding_type) ## embedding 256 classical data to amplitude of 8 qubits
QCNN_structure1(unitary.U_SU4, params, U_params)
torch.nn.Linear(16, 16) ## classical layer 1
QCNN_structure2(unitary.U_SU4, params, U_params)
torch.nn.Linear(4, 4) ## classical layer 2
QCNN_structure3(unitary.U_SU4, params, U_params)
result = qml.expval(qml.PauliZ(4))
return result
I checked my hybrid model including above codes runs well without any errors.
However, I don’t have confidence whether this code can run with my goal.
(i.e., the output of QCNN structure_1 pass to classical layer 1 and the output from classical layer 1 to QCNN_structure 2)
How can I check this? And is it possible to write code for my goal?
- quamtum layer between classical layers
: Like the first question I mentioned above, I considered hybrid model with quantum layer between classical layers. In this case, how can I use quantum layer without measurement between classical layers?
For example, (this is pseudo code)
classical_layer1 (torch.nn.Linear(256, 256))
quantum_layer1 (amplitude embedding with 8 qubits and without measurement)
classical_layer2 (torch.nn.Linear(64, 64)
Is it possible to use intermediate data from quantum circuit without measurement step as a input data for classical layer?
Thank you in advance!