Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
267 views
in Technique[技术] by (71.8m points)

Train weights on readout of a PQC layer in TensorFlow Quantum?

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

56.9k users

...