Skip to content

Commit

Permalink
fix: working derivative wrt x
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoRobbiati committed Nov 13, 2024
1 parent eac535e commit 6e3870d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/qiboml/operations/differentiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]])]
Expand Down

0 comments on commit 6e3870d

Please sign in to comment.