I have a Tensorflow Quantum model of the following form:
readout_op = [cirq.Z(qubit) for qubit in qubits]
model = tf.keras.Sequential()
model.add(tf.keras.layers.Input(shape=(), dtype=tf.dtypes.string))
model.add(
tfq.layers.PQC(
model_circuit=circuit,
operators=readout_op))
The readout in this simple example is just a computational basis measurement on each qubit.
I would like to extend the range of outputs beyond [-1, 1] by adding a factor to each Pauli term, but I do not necessarily know what the ideal factor for my model is. Therefore I want to make this factor trainable, i.e. change the readout op to:
readout_op = [symbol*cirq.Z(qubit) for qubit in qubits]
where symbol is a sympy symbol as those used in the circuit of the PQC layer. When I do this I get a TypeError: unsupported operand type(s) for : 'Symbol' and 'SingleQubitPauliStringGateOperation'
Is there a way to make the output scaling trainable along with the parameters in the PQC layer?
question from:
https://stackoverflow.com/questions/65845617/train-weights-on-readout-of-a-pqc-layer-in-tensorflow-quantum 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…