I am using qml.ttn with keras layer. But it throws an error TypeError: QNode must include an argument with name inputs for inputting data. It might be due to weights shape.
def block(weights, wires):
qml.CNOT(wires=[wires[0],wires[1]])
qml.RY(weights[0], wires=wires[0])
qml.RY(weights[1], wires=wires[1])
n_wires = 4
n_block_wires = 2
n_params_block = 2
n_blocks = qml.TTN.get_n_blocks(range(n_wires),n_block_wires)
dev = qml.device(“default.qubit.tf”, wires=4)
@qml.qnode(dev, interface=“tf”, diff_method=“backprop”)
def circuit(x, weights):
qml.AngleEmbedding(x, wires=range(4))
for w in weights:
qml.TTN(range(n_wires),n_block_wires,block, n_params_block, w)
return qml.expval(qml.PauliZ(3))
weights_shape={“weights”: (3,2)}
input_m = tf.keras.layers.Input(shape=(4,))
keras_1 = qml.qnn.KerasLayer(circuit, weights_shape, output_dim=1, name = “keras_1”)(input_m)
output = tf.keras.layers.Dense(1, activation=‘softmax’, name = “dense_1”)(keras_1)
Model creation
model = tf.keras.Model(inputs=input_m, outputs=output)