version question

model.params = opt.step(cost, approx=‘block-diag’)

Here is the error message:

ValueError: The objective function must be encoded as a single QNode for the natural gradient to be automatically computed. Otherwise, metric_tensor_fn must be explicitly provided to the optimizer.

Hi @w2534765383, welcome to the Forum!

Is your question regarding any of the PennyLane Coding Challenges?
Or are you having difficulty using a specific PennyLane function?

If it’s the former please indicate what challenge you’re trying. If it’s the latter please share a minimal reproducible example.

A minimal reproducible example (or minimal working example) is the simplest version of the code that reproduces the problem. It should be self-contained, including 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, etc. (for example gates and functions that can be removed to simplify the code). If you’re not sure what this means then please make sure to check out this video.