tensorflow / tensorflow/quantum

Can't measure the fidelity of the states.

Open
#745 28 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/question status/needs-more-info
Dominant language
Python
Stars
2.2k
Forks
665
PR merge metrics
No merged PRs in 30d

Description

I have measure the quantum states using tfq.layers.State(). The output of tfq.layers.State() is of the form tf.RaggedTensor. Now I have measured two different states, using the same method. (say state1 and state2)
After using cirq.fidelity(state1, state2), I am getting the following error:

ValueError: Exception encountered when calling layer "generator__discriminator_6" (type Generator_Discriminator).

Failed to infer the qid shape of the given states. Please specify the qid shape explicitly using the `qid_shape` argument.

Call arguments received:
  • inputs=tf.Tensor(shape=(1,), dtype=string)

Why is it so? And how can I measure the fidelity of the states using tfq.layers.State()?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported tfq.layers.State() output and the cirq.fidelity(state1, state2) call, then trace how the resulting tf.RaggedTensor is passed into fidelity. Check the relevant TensorFlow Quantum and Cirq API behavior for qid_shape handling. Done means the cause of the error is documented and a valid way to measure fidelity from two State() results is demonstrated.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, tensorflow
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.