I've had to write two different functions (shown below), but I want to combine the two functions into one. Is there a way to do this?
softmax_a_set() takes a list of numpy arrays, applies
softmax() to each individual numpy array, and then returns a list of processed numpy arrays.
def softmax(a_vector): """Compute a logit for a vector.""" denom = sum(numpy.exp(a_vector)) logit = numpy.exp(a_vector)/denom return logit def softmax_a_set(a_set): """computes logits for all vectors in a set""" softmax_set = numpy.zeros(a_set.shape) for x in range(0, len(a_set)): softmax_set[x] = softmax(a_set[x]) return softmax_set