From 6e3870d0f271bb4cce1e1948c6c16ebcdc5eb243 Mon Sep 17 00:00:00 2001 From: MatteoRobbiati Date: Wed, 13 Nov 2024 19:57:55 +0100 Subject: [PATCH] fix: working derivative wrt x --- src/qiboml/operations/differentiation.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/qiboml/operations/differentiation.py b/src/qiboml/operations/differentiation.py index 414aa44..1551a91 100644 --- a/src/qiboml/operations/differentiation.py +++ b/src/qiboml/operations/differentiation.py @@ -79,12 +79,12 @@ def evaluate(self, x: ndarray, encoding, training, decoding, backend, *parameter backend=backend, ) backward = decoding(x) - derivative_k += generator_eigenval * (forward - backward) + derivative_k += float( + generator_eigenval * (forward - backward) + ) # restore original parameter gate.parameters = original_parameter - x_gradient.append(derivative_k) - gradients = [np.array([[(der,) * len(x_gradient)]]) for der in x_gradient] - print(gradients) + gradients = [np.array([[[der for der in x_gradient]]])] else: # pad the gradients in case data are not uploaded into gates gradients = [np.array([[(0.0,) * x_size]])]