Help to building cost function

Hi @Kaushik,

That’s not the issue on its own. It’s something else that you’re doing in your code which is causing the issue.

I’ve used the SSVQE notebook here and modified single_cost as I mentioned before. I’ve added the comment “#modified” to the lines that I’ve modified. You can see my modified code below. If you run it with the latest version of PennyLane it runs well. Note that I haven’t modified total_cost here, and no errors show up from the line cost +=w[state_idx]*single_cost(params, state_idx=state_idx).

I would suggest that you start from this notebook and make one change at a time until you reach an issue. Then you can identify the cause for your issue.

SSVQE_Tutorial_mod.ipynb (321.3 KB)

I hope this helps you.

1 Like