MCPcopy Create free account
hub / github.com/PythonOT/POT / logsumexp

Function logsumexp

ot/dr.py:56–59  ·  view source on GitHub ↗

r"""Log-sum-exp reduction compatible with autograd (no numpy implementation)

(M, axis)

Source from the content-addressed store, hash-verified

54
55
56def logsumexp(M, axis):
57 r"""Log-sum-exp reduction compatible with autograd (no numpy implementation)"""
58 amax = np.amax(M, axis=axis, keepdims=True)
59 return np.log(np.sum(np.exp(M - amax), axis=axis)) + np.squeeze(amax, axis=axis)
60
61
62def sinkhorn_log(w1, w2, M, reg, k):

Callers 1

sinkhorn_logFunction · 0.85

Calls 4

logMethod · 0.45
sumMethod · 0.45
expMethod · 0.45
squeezeMethod · 0.45

Tested by

no test coverage detected