Class: Gsplat::Training::Losses::StructuralSimilarity

Inherits:
Autograd::Function show all
Defined in:
lib/gsplat/training/losses.rb

Overview

Structural similarity with the standard 11x11, sigma 1.5 window.

Class Method Summary collapse

Methods inherited from Autograd::Function

apply

Class Method Details

.backward(context, grad_output) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Propagates the SSIM score gradient.



48
49
50
# File 'lib/gsplat/training/losses.rb', line 48

def backward(context, grad_output)
  Math::Ssim.backward(context.saved_values.first, grad_output)
end

.forward(context, image_a, image_b, layout:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Evaluates mean SSIM and stores convolution intermediates.



40
41
42
43
44
# File 'lib/gsplat/training/losses.rb', line 40

def forward(context, image_a, image_b, layout:)
  score, cache = Math::Ssim.forward(image_a, image_b, layout: layout)
  context.save(cache)
  image_a.class.cast(score)
end