#NEWLINE# def softmax( w ) : #NEWLINE# #INDENT# w = np . array ( w ) #NEWLINE# maxes = np . amax ( w , axis = 1 ) #NEWLINE# maxes = maxes . reshape ( maxes . shape [ 0 ] , 1 ) #NEWLINE# e = np . exp ( ( w - maxes ) ) #NEWLINE# dist = ( w / np . sum ( e , axis = 1 ) [ : , None ] ) #NEWLINE# return dist