Ask Your Question

Revision history [back]

Elementwise functions for deep learning

Let's say I want to define a softmax function over a vector input.

In Python/Numpy that would look something like this

X = np.array([x1, x2, x3]) 
numerators = np.exp(X)
denominator = np.sum(numerators)
softmax_probs = numerators / denominators # [e^x1 / sum(e^x1, e^x2, e^x3), e^x2 / sum(e^x1, e^x2, e^x3),...

What would be a good way of going about this in sage?