Skip to content

Commit

Permalink
hotfix(HatBasisQFE): fix negative sqrt
Browse files Browse the repository at this point in the history
  • Loading branch information
MazenAli committed Feb 6, 2024
1 parent 1769f38 commit 6c60ae1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.6.2] - 2024-02-06

### Fixed

- Hat basis negative close to 0 values, sqrt in HatBasisQFE returned nan

## [0.6.1] - 2024-02-05

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "qulearn"
version = "0.6.1"
version = "0.6.2"
description = "Streamlining quantum and classical machine learning model development."
authors = ["Mazen Ali <[email protected]>"]
readme = "README.md"
Expand Down
5 changes: 3 additions & 2 deletions qulearn/qlayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,9 @@ def circuit(self, x: Tensor) -> None:
a, b = self.basis.nonz_vals(x)

if self.sqrt:
a = torch.sqrt(a)
b = torch.sqrt(b)
# sometimes the values are close to 0 and negative
a = torch.sqrt(torch.abs(a))
b = torch.sqrt(torch.abs(b))

if position == -1:
self.norm = b.item()
Expand Down

0 comments on commit 6c60ae1

Please sign in to comment.