MCPcopy Create free account
hub / github.com/DragonisCV/RAM / reduce_func

Function reduce_func

scripts/analysis_utils.py:44–53  ·  view source on GitHub ↗

Return the corresponding reduction function.

(method)

Source from the content-addressed store, hash-verified

42 return mask
43
44def reduce_func(method):
45 """Return the corresponding reduction function."""
46 if method == 'sum':
47 return torch.sum
48 elif method == 'mean':
49 return torch.mean
50 elif method == 'count':
51 return lambda x: sum(x.size())
52 else:
53 raise NotImplementedError()
54
55def attr_grad(tensor, reduce='sum'):
56 """Calculate attribute gradient."""

Callers 2

attr_gradFunction · 0.85
attr_gaborFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected