Beispiel #1
0
def softmax(m):
  #maxval = np.max(m, axis=0)
  #centered = m - maxval
  #class_normalizer = np.log(np.max(np.exp(centered), axis=0)) + maxval
  #return np.exp(m - class_normalizer)
  maxval = spartan.max(m, axis=0)
  centered = m - maxval
  class_normalizer = spartan.log(spartan.max(spartan.exp(centered), axis=0)) + maxval
  return spartan.exp(m - class_normalizer)
 def test_max(self):
     src = np.asarray([1, 1, 1, 2, 2, 5, 5, 10])
     Assert.all_eq(spartan.max(spartan.from_numpy(src)).glom(), np.max(src))
Beispiel #3
0
 def test_max(self):
   src = np.asarray([1, 1, 1, 2, 2, 5, 5, 10])
   Assert.all_eq(
       spartan.max(spartan.from_numpy(src)).glom(),
       np.max(src))