0
$\begingroup$

I am following the tutorial from https://qiskit-community.github.io/qiskit-machine-learning/tutorials/02_neural_network_classifier_and_regressor.html

# construct feature map, ansatz, and optimizer
feature_map = ZZFeatureMap(num_inputs)
ansatz = RealAmplitudes(num_inputs, reps=1)

# construct variational quantum classifier
vqc = VQC(
    feature_map=feature_map,
    ansatz=ansatz,
    loss="cross_entropy",
    optimizer=COBYLA(maxiter=30),
    callback=callback_graph,
)

# callback function that draws a live plot when the .fit() method is called
def callback_graph(weights, obj_func_eval):
    clear_output(wait=True)
    objective_func_vals.append(obj_func_eval)
    plt.title("Objective function value against iteration")
    plt.xlabel("Iteration")
    plt.ylabel("Objective function value")
    plt.plot(range(len(objective_func_vals)), objective_func_vals)
    plt.show()

I am attempting to initialize my own weights for the vqc, but I failed to identify anything in documentation helps as per https://qiskit-community.github.io/qiskit-machine-learning/stubs/qiskit_machine_learning.algorithms.VQC.html#vqc

How can I do to achieve this?

$\endgroup$

1 Answer 1

0
$\begingroup$

The initial_point defines the starting point of the ansatz parameters (weights) for the optimization. There are examples in the test case here if that's of help https://github.com/qiskit-community/qiskit-machine-learning/blob/main/test/algorithms/classifiers/test_vqc.py

$\endgroup$
2
  • $\begingroup$ Hi, I have a quick test with the solution provided, I think it works. $\endgroup$
    – CharonEXE
    Feb 18 at 11:58
  • $\begingroup$ So in the documentation mentioned it as initial_point as well, is that a common terminology in quantum machine learning? $\endgroup$
    – CharonEXE
    Feb 18 at 12:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.