Implementation of the softmax layer