Getting error :Runtime Error. ops operation Rot

Hi
I get the following error

Runtime Error. ops operation Rot(<autograd.numpy.numpy_boxes.ArrayBox object at 0x0000029E30F68A80>, <autograd.numpy.numpy_boxes.ArrayBox object at 0x0000029E30F6AE80>, <autograd.numpy.numpy_boxes.ArrayBox object at 0x0000029E30F68500>, wires=[0]) must occur prior to measurements. Please place earlier in the queue.

coeffs = [1., 1., 1.]
obs = [qml.PauliX(0), qml.PauliZ(0),qml.PauliX(0)]
H = qml.Hamiltonian(coeffs, obs)

def circuit(params, wires=0):
    qml.RX(params[0], wires=wires)
    qml.RZ(params[0], wires=wires)
    qml.RX(params[0], wires=wires)
    
# This is the cost function
@qml.qnode(dev)  
def cost_function(params):
    circuit(params)
    return qml.expval(H)   

Hi @Rajesh_Chaurasia ,

Unfortunately the code you shared doesn’t seem to be the full code you’re using (I can’t see what ‘params’ are for you).

Could you please provide the following information?

  1. The output of qml.about()
  2. A minimal (but self-contained) working example
    This is the simplest version of the code that reproduces the problem. It should include all necessary imports, data, functions, etc., so that we can copy-paste the code and reproduce the problem. However it shouldn’t contain any unnecessary data, functions, …, for example gates and functions that can be removed to simplify the code.
  3. The full error traceback.

If you’re not sure what these mean then make sure to check out this video :smiley:

Hi Catalina
I am uploading the file here , hope its fine.
TEST-CHALLENGE.txt (5.4 KB)

Thanks for your reply.I am tying to correct issues as mentioned by you

Hi @Rajesh_Chaurasia ,

Is your question about a specific coding challenge or a specific codercise?

Also, could you please post these two key pieces of information?

  1. The output of qml.about()
  2. The full error traceback

Thanks!