mirror of
https://github.com/wassname/rl-portfolio-management.git
synced 2026-06-27 18:06:31 +08:00
better softmax clipping
This commit is contained in:
@@ -16,7 +16,8 @@ def MDD(returns):
|
||||
|
||||
def softmax(w, t=1.0):
|
||||
"""softmax implemented in numpy."""
|
||||
w = np.clip(w, -1000, 50) # avoid inf/nan
|
||||
log_eps = np.log(eps)
|
||||
w = np.clip(w, -log_eps, log_eps) # avoid inf/nan
|
||||
e = np.exp(np.array(w) / t)
|
||||
dist = e / np.sum(e)
|
||||
return dist
|
||||
|
||||
Reference in New Issue
Block a user