MCPcopy
hub / github.com/alex-damian/pulse / bicubic_kernel

Method bicubic_kernel

bicubic.py:7–18  ·  view source on GitHub ↗

This equation is exactly copied from the website below: https://clouard.users.greyc.fr/Pantheon/experiments/rescaling/index-en.html#bicubic

(self, x, a=-0.50)

Source from the content-addressed store, hash-verified

5
6class BicubicDownSample(nn.Module):
7 def bicubic_kernel(self, x, a=-0.50):
8 """
9 This equation is exactly copied from the website below:
10 https://clouard.users.greyc.fr/Pantheon/experiments/rescaling/index-en.html#bicubic
11 """
12 abs_x = torch.abs(x)
13 if abs_x <= 1.:
14 return (a + 2.) * torch.pow(abs_x, 3.) - (a + 3.) * torch.pow(abs_x, 2.) + 1
15 elif 1. < abs_x < 2.:
16 return a * torch.pow(abs_x, 3) - 5. * a * torch.pow(abs_x, 2.) + 8. * a * abs_x - 4. * a
17 else:
18 return 0.0
19
20 def __init__(self, factor=4, cuda=True, padding='reflect'):
21 super().__init__()

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected