# Calculating Softmax derivative independent of cost function

Note: there is a nearly identical question on Stack Overflow. However, I seem to be missing something... or maybe it's just that Python isn't my first language ;)

For a neural network library, I've implemented a number of activation and cost functions along with their derivatives. Any combination of activation and cost function can be chosen for the network's output layer.

For backpropagation, the output layer's error gradient with respect to each node's input is simply the product of the activation derivative and cost derivative (forgive the pseudocode):

$gradient_j = activation.derivative(y_j) * cost.derivative(y_j, t_j)$

where $y$ is the network's final (activated) output and $t$ is the target output.

How can I implement my Softmax derivative to work here? So far, all activation gradients have been computable using only the $y$ value: logistic, tanh, etc. Softmax appears to be a special case; can someone help me out?

• The other site is appropriate for this question and this site is not. Maybe you can get the answer you want by following the post you linked us to. – Michael R. Chernick Apr 12 '17 at 0:04
• @Michael Chernick - this site has far more posts re: machine learning than Stack Overflow. S.O. is good for coding help with specific languages; I'm looking for a mathematical explanation for my problem. The link I provided has Python help, but not much math. – Hundley Apr 12 '17 at 0:42
• Yes but not on software. Why do you think the other post is on SO? – Michael R. Chernick Apr 12 '17 at 1:15
• @hundley $\LaTeX$ might help, although I suspect there are plenty of people on here that will be able to answer your question as is – Taylor Apr 12 '17 at 4:10
• @Taylor I gave a LaTeX a shot, but unfortunately I'm not a guru when it comes to proper notation - hence the pseudocode. I think this is what gave Michael the impression I was looking for coding help. Hopefully somebody has an idea on how to solve this... – Hundley Apr 12 '17 at 4:32