Skip to content

Commit

Permalink
fix: small fix to expectation layer
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoLiegiBastonLiegi committed Jul 17, 2024
1 parent 2e0c1bd commit 42c0a1b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/qiboml/models/encoding_decoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,10 @@ def __post_init__(self):

def forward(self, x: Circuit) -> "ndarray":
if self.nshots is None:
# breakpoint()
return self.observable.expectation(
super().forward(x).state(),
)
).reshape(1, 1)
else:
return self.observable.expectation_from_samples(
super().forward(x).samples(),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_layers(module, layer_type=None):
for name, layer in inspect.getmembers(module, inspect.isclass):
if layer.__module__ == module.__name__:
if layer_type is not None:
if issubclass(layer, layer_type):
if issubclass(layer, layer_type) and not layer is layer_type:
pass
else:
continue
Expand Down

0 comments on commit 42c0a1b

Please sign in to comment.