quantum
quantum copied to clipboard
'cirq.sim.simulator' has no attribute 'SimulatesExpectationValues'
Build the quantum model layer
theta = sympy.Symbol('theta') q_model = cirq.Circuit(cirq.ry(theta)(qubit)) q_data_input = tf.keras.Input( shape=(), dtype=tf.dtypes.string) expectation = tfq.layers.PQC(q_model, cirq.Z(qubit)) expectation_output = expectation(q_data_input)
Attach the classical SoftMax classifier
classifier = tf.keras.layers.Dense(2, activation=tf.keras.activations.softmax) classifier_output = classifier(expectation_output) model = tf.keras.Model(inputs=q_data_input, outputs=classifier_output)
Standard compilation for classification
model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=0.1), loss=tf.keras.losses.CategoricalCrossentropy()) tf.keras.utils.plot_model(model, show_shapes=True, dpi=70)
AttributeError Traceback (most recent call last)
~/opt/anaconda3/lib/python3.8/site-packages/tensorflow_quantum/python/layers/high_level/pqc.py in init(self, model_circuit, operators, repetitions, backend, differentiator, initializer, regularizer, constraint, **kwargs) 232 233 not_default = backend is not 'noiseless' --> 234 not_default &= backend is not None # legacy backend=None support. 235 if not isinstance( 236 backend,
AttributeError: module 'cirq.sim.simulator' has no attribute 'SimulatesExpectationValues'
Hi @sassan72 thanks for opening this issue, could you please provide a working snippet of code I could run to reproduce the problem on my end ? Right now the code mixed in between the bolded text is kind of hard to follow.
I got the same error when import qsimcirq
after import cirq