Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions monai/losses/spectral_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ def __init__(
self.fft_norm = fft_norm

def forward(self, input: torch.Tensor, target: torch.Tensor) -> torch.Tensor:
input_amplitude = self._get_fft_amplitude(target)
target_amplitude = self._get_fft_amplitude(input)
input_amplitude = self._get_fft_amplitude(input)
target_amplitude = self._get_fft_amplitude(target)

# Compute distance between amplitude of frequency components
# See Section 3.3 from https://arxiv.org/abs/2005.00341
Expand Down
6 changes: 3 additions & 3 deletions monai/losses/ssim_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ def forward(self, input: torch.Tensor, target: torch.Tensor) -> torch.Tensor:
# 2D data
x = torch.ones([1,1,10,10])/2
y = torch.ones([1,1,10,10])/2
print(1-SSIMLoss(spatial_dims=2)(x,y))
print(SSIMLoss(spatial_dims=2)(x,y))
# pseudo-3D data
x = torch.ones([1,5,10,10])/2 # 5 could represent number of slices
y = torch.ones([1,5,10,10])/2
print(1-SSIMLoss(spatial_dims=2)(x,y))
print(SSIMLoss(spatial_dims=2)(x,y))
# 3D data
x = torch.ones([1,1,10,10,10])/2
y = torch.ones([1,1,10,10,10])/2
print(1-SSIMLoss(spatial_dims=3)(x,y))
print(SSIMLoss(spatial_dims=3)(x,y))
"""
ssim_value = self.ssim_metric._compute_tensor(input, target).view(-1, 1)
loss: torch.Tensor = 1 - ssim_value
Expand Down
Loading