MCPcopy
hub / github.com/Totoro97/NeuS / gradient

Method gradient

models/fields.py:96–107  ·  view source on GitHub ↗
(self, x)

Source from the content-addressed store, hash-verified

94 return self.forward(x)
95
96 def gradient(self, x):
97 x.requires_grad_(True)
98 y = self.sdf(x)
99 d_output = torch.ones_like(y, requires_grad=False, device=y.device)
100 gradients = torch.autograd.grad(
101 outputs=y,
102 inputs=x,
103 grad_outputs=d_output,
104 create_graph=True,
105 retain_graph=True,
106 only_inputs=True)[0]
107 return gradients.unsqueeze(1)
108
109
110# This implementation is borrowed from IDR: https://github.com/lioryariv/idr

Callers 1

render_coreMethod · 0.80

Calls 1

sdfMethod · 0.95

Tested by

no test coverage detected