Skip to content

Instantly share code, notes, and snippets.

@stfuchs
Created April 25, 2018 01:09
Show Gist options
  • Save stfuchs/eb8d50accfce332fba1ac70dca938e32 to your computer and use it in GitHub Desktop.
Save stfuchs/eb8d50accfce332fba1ac70dca938e32 to your computer and use it in GitHub Desktop.
f1 = lambda x: 1./np.exp(0.1*(x + 80.))
f2 = lambda x: -.26*(x+58)
def weight(i, fs):
return lambda x: np.exp(fs[i](x)) / np.sum([np.exp(f(x)) for f in fs])
def softmax(fs):
return lambda x: np.sum([f(x)*weight(i,fs)(x) for i,f in enumerate(fs)])
softmax([f1,f2])(np.linspace(-80,0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment