MCPcopy Create free account
hub / github.com/HiLab-git/ACELoss / first_derivative

Function first_derivative

aceloss.py:94–109  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

92 based on total variations and mean curvature
93 """
94 def first_derivative(input):
95 u = input
96 m = u.shape[2]
97 n = u.shape[3]
98
99 ci_0 = (u[:, :, 1, :] - u[:, :, 0, :]).unsqueeze(2)
100 ci_1 = u[:, :, 2:, :] - u[:, :, 0:m - 2, :]
101 ci_2 = (u[:, :, -1, :] - u[:, :, m - 2, :]).unsqueeze(2)
102 ci = torch.cat([ci_0, ci_1, ci_2], 2) / 2
103
104 cj_0 = (u[:, :, :, 1] - u[:, :, :, 0]).unsqueeze(3)
105 cj_1 = u[:, :, :, 2:] - u[:, :, :, 0:n - 2]
106 cj_2 = (u[:, :, :, -1] - u[:, :, :, n - 2]).unsqueeze(3)
107 cj = torch.cat([cj_0, cj_1, cj_2], 3) / 2
108
109 return ci, cj
110
111 def second_derivative(input, ci, cj):
112 u = input

Callers 1

elasticaFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected