Data re-uploading impelementation in hybrid NN with keras layer

Dear josh-san,

Thanks for the advice.
tf.split worked well.
Great.

dev = qml.device("lightning.qubit", wires=n_qubits)

@qml.qnode(dev, diff_method='adjoint', immutable=False)
def qnode(inputs, weights):
    weights_each_layer = tf.split(weights, num_or_size_splits=layers, axis=0)
    for i in range(layers):
        qml.templates.AngleEmbedding(inputs, wires=range(n_qubits))
        qml.templates.StronglyEntanglingLayers(weights_each_layer[i], wires=range(n_qubits))
    return qml.expval(qml.PauliZ(0))

weight_shapes = {"weights": (layers, n_qubits,3)}
Epoch 1/3
4/4 [==============================] - 1s 271ms/step - loss: 0.9884 - val_loss: 1.0154
Epoch 2/3
4/4 [==============================] - 1s 264ms/step - loss: 0.6703 - val_loss: 0.6914
Epoch 3/3
4/4 [==============================] - 1s 262ms/step - loss: 0.3764 - val_loss: 0.3741
1 Like