MCPcopy Index your code
hub / github.com/Extraltodeus/DistanceSampler / diff_step

Function diff_step

custom_samplers.py:219–224  ·  view source on GitHub ↗
(a, b, s)

Source from the content-addressed store, hash-verified

217
218@torch.no_grad()
219def diff_step(a, b, s):
220 n = torch.linalg.matrix_norm(a, keepdim=True)
221 x = a.div(n)
222 y = b.div(torch.linalg.matrix_norm(b, keepdim=True))
223 y = n * y.sub(x.mul(torch.mul(x, y).sum().clamp(min=-1.0, max=1.0)))
224 return a - y * s
225
226def perp_step_wrap(s=0.5):
227 @torch.no_grad()

Callers 2

sample_distance_advancedFunction · 0.85
perp_stepFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected