Skip to content

Commit

Permalink
Merge pull request #8 from OkuyanBoga/Bug#600-qkt-deepcopies-kernel-i…
Browse files Browse the repository at this point in the history
…nternally,-fails-with-runtime-primitives

Bug#600 qkt deepcopies kernel internally, fails with runtime primitives
  • Loading branch information
OkuyanBoga authored Feb 19, 2024
2 parents 9ab6729 + 6042e8a commit 858f42b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
7 changes: 0 additions & 7 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,8 @@

translations_list = [
("en", "English"),
("bn_BN", "Bengali"),
("fr_FR", "French"),
("hi_IN", "Hindi"),
("ja_JP", "Japanese"),
("ko_KR", "Korean"),
("ru_RU", "Russian"),
("es_UN", "Spanish"),
("ta_IN", "Tamil"),
("tr_TR", "Turkish"),
]
language = "en"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This code is part of a Qiskit project.
#
# (C) Copyright IBM 2021, 2023.
# (C) Copyright IBM 2021, 2024.
#
# This code is licensed under the Apache License, Version 2.0. You may
# obtain a copy of this license in the LICENSE.txt file in the root directory
Expand All @@ -13,7 +13,6 @@
"""Quantum Kernel Trainer"""
from __future__ import annotations

import copy
from functools import partial
from typing import Sequence

Expand Down Expand Up @@ -198,13 +197,17 @@ def fit(
msg = "Quantum kernel cannot be fit because there are no user parameters specified."
raise ValueError(msg)

# Bind inputs to objective function
output_kernel = copy.deepcopy(self._quantum_kernel)

# Randomly initialize the initial point if one was not passed
if self._initial_point is None:
self._initial_point = algorithm_globals.random.random(num_params)

# Bind inputs to objective function
output_kernel = type(self._quantum_kernel)(
feature_map=self._quantum_kernel.feature_map,
training_parameters=self._quantum_kernel.training_parameters,
)
output_kernel.assign_training_parameters(parameter_values=self.initial_point)

# Perform kernel optimization
loss_function = partial(
self._loss.evaluate, quantum_kernel=self.quantum_kernel, data=data, labels=labels
Expand Down

0 comments on commit 858f42b

Please sign in to comment.