Closed atul20027 closed 3 months ago
Already i have implemented the code but when i am submitting to grade_lab1_ex6 it is giving error " you need to implement the code to get the result".
def cost_func(params, ansatz, hamiltonian, estimator,callback1_dict): """Return estimate of energy from estimator
Parameters: params (ndarray): Array of ansatz parameters ansatz (QuantumCircuit): Parameterized ansatz circuit hamiltonian (SparsePauliOp): Operator representation of Hamiltonian estimator (EstimatorV2): Estimator primitive instance Returns: float: Energy estimate """ pub = (ansatz,hamiltonian,params) result = estimator.run([pub]) energy = result.result()[0].data.evs
callback1_dict["iters"] += 1 callback1_dict["prev_vector"] = params callback1_dict["cost_history"].append(result)
print(energy) return energy, result
grade_lab1_ex6(cost_func) ## while running this, got the below error error : [0.70898438] You need to implement code to get a result.
Include the hamiltonian and the parameters in a list: [hamiltonean] , [params]
Already i have implemented the code but when i am submitting to grade_lab1_ex6 it is giving error " you need to implement the code to get the result".
def cost_func(params, ansatz, hamiltonian, estimator,callback1_dict): """Return estimate of energy from estimator
return energy,result
Don't change any code past this line
grade_lab1_ex6(cost_func) ## while running this, got the below error error : [0.70898438] You need to implement code to get a result.