def softmax(X, copy=True):
 if copy:
  X = np.copy(X)
 max_prob = np.max(X, axis=1).reshape(((-1), 1))
 X -= max_prob
 np.exp(X, X)
 sum_prob = np.sum(X, axis=1).reshape(((-1), 1))
 X /= sum_prob
 return X

def softmax ( X , copy = True ) : if copy : X = np . copy ( X ) max_prob = np . max ( X , axis = 1 ) . reshape ( ( ( - 1 ) , 1 ) ) X -= max_prob np . exp ( X , X ) sum_prob = np . sum ( X , axis = 1 ) . reshape ( ( ( - 1 ) , 1 ) ) X /= sum_prob return X
channelwise softmax function .