From ce2f19b72131aeca7d45ba94183df96da30632b4 Mon Sep 17 00:00:00 2001 From: StefanWahl Date: Thu, 20 Jun 2024 16:15:07 +0200 Subject: [PATCH 1/2] Bug fix InvertibleSigmoid --- FrEIA/modules/fixed_transforms.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/FrEIA/modules/fixed_transforms.py b/FrEIA/modules/fixed_transforms.py index 13b9a9d..4350447 100644 --- a/FrEIA/modules/fixed_transforms.py +++ b/FrEIA/modules/fixed_transforms.py @@ -175,8 +175,10 @@ def forward(self, x_or_z: Iterable[torch.Tensor], c: Iterable[torch.Tensor] = No # the following is the diagonal Jacobian as sigmoid is an element-wise op logJ = torch.log(1 / ((1 + torch.exp(_input)) * (1 + torch.exp(-_input)))) # determinant of a log diagonal Jacobian is simply the sum of its diagonals - detLogJ = logJ.sum(1) + detLogJ = sum_except_batch(logJ) + if not rev: return ((result, ), detLogJ) else: return ((result, ), -detLogJ) + \ No newline at end of file From bcbc2bd29d3ed4d1eb7c15144b6e7f1636cf3694 Mon Sep 17 00:00:00 2001 From: StefanWahl Date: Mon, 24 Jun 2024 17:36:31 +0200 Subject: [PATCH 2/2] Bug fix --- FrEIA/modules/fixed_transforms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FrEIA/modules/fixed_transforms.py b/FrEIA/modules/fixed_transforms.py index 4350447..ed26063 100644 --- a/FrEIA/modules/fixed_transforms.py +++ b/FrEIA/modules/fixed_transforms.py @@ -1,5 +1,5 @@ from . import InvertibleModule - +from utils import sum_except_batch from typing import Union, Iterable, Tuple import numpy as np