Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
#6 Add the callback function
Browse files Browse the repository at this point in the history
  • Loading branch information
ksk0629 committed Oct 18, 2024
1 parent b61267b commit e10c08b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion scripts/run_example_estimator_qnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sklearn.model_selection import train_test_split

from src.qnn_builder import QNNBuilder
from src.utils import fix_seed, generate_line_dataset
from src.utils import fix_seed, generate_line_dataset, callback_print

if __name__ == "__main__":
# Fix the random seed.
Expand All @@ -26,6 +26,7 @@
classifier = NeuralNetworkClassifier(
example_estimator_qnn,
optimizer=qiskit_algorithms.optimizers.COBYLA(maxiter=200),
callback=callback_print,
)
# Fit the model.
x = np.asarray(train_images)
Expand Down
3 changes: 2 additions & 1 deletion scripts/run_example_exact_aer_estimator_qnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sklearn.model_selection import train_test_split

from src.qnn_builder import QNNBuilder
from src.utils import fix_seed, generate_line_dataset
from src.utils import fix_seed, generate_line_dataset, callback_print

if __name__ == "__main__":
# Fix the random seed.
Expand All @@ -26,6 +26,7 @@
classifier = NeuralNetworkClassifier(
example_estimator_qnn,
optimizer=qiskit_algorithms.optimizers.COBYLA(maxiter=200),
callback=callback_print,
)
# Fit the model.
x = np.asarray(train_images)
Expand Down
3 changes: 2 additions & 1 deletion scripts/run_example_noisy_aer_estimator_qnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sklearn.model_selection import train_test_split

from src.qnn_builder import QNNBuilder
from src.utils import fix_seed, generate_line_dataset
from src.utils import fix_seed, generate_line_dataset, callback_print

if __name__ == "__main__":
# Fix the random seed.
Expand All @@ -26,6 +26,7 @@
classifier = NeuralNetworkClassifier(
example_estimator_qnn,
optimizer=qiskit_algorithms.optimizers.COBYLA(maxiter=200),
callback=callback_print,
)
# Fit the model.
x = np.asarray(train_images)
Expand Down

0 comments on commit e10c08b

Please sign in to comment.