def check_forward(self, x_data): xp = cuda.get_array_module(x_data) y = maximum_entropy_mellowmax(x_data) self.assertEqual(y.data.dtype, self.dtype) print('y', y.data) # Outputs must be positive xp.testing.assert_array_less(xp.zeros_like(y.data), y.data) # Sums must be ones sums = xp.sum(y.data, axis=1) testing.assert_allclose(sums, xp.ones_like(sums)) # Expectations must be equal to memllowmax's outputs testing.assert_allclose(xp.sum(y.data * x_data, axis=1), mellowmax(x_data, axis=1).data)
def all_prob(self): with chainer.force_backprop_mode(): return mellowmax.maximum_entropy_mellowmax(self.values)
def all_prob(self): return mellowmax.maximum_entropy_mellowmax(self.values)