Skip to content

Instantly share code, notes, and snippets.

@agastidukare
Created April 1, 2020 01:45
Show Gist options
  • Save agastidukare/5eadf0ee3cb36947437e22786dc1dc2c to your computer and use it in GitHub Desktop.
Save agastidukare/5eadf0ee3cb36947437e22786dc1dc2c to your computer and use it in GitHub Desktop.
def predict(params, inputs):
activations = inputs
for w, b in params[:-1]:
outputs = np.dot(activations, w) + b
activations = np.tanh(outputs)
final_w, final_b = params[-1]
logits = np.dot(activations, final_w) + final_b
return logits - logsumexp(logits, axis=1, keepdims=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment