Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions FrEIA/modules/fixed_transforms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from . import InvertibleModule

from utils import sum_except_batch
from typing import Union, Iterable, Tuple

import numpy as np
Expand Down Expand Up @@ -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)