def test_absolute(): X, Y = T.matrix(), T.matrix() X.tag.test_value = test_X Y.tag.test_value = test_Y dist = absolute(X, Y).sum() f = theano.function([X, Y], dist, mode='FAST_COMPILE') res = f(test_X, test_Y) assert res == 0.21, 'absolute loss not working'
def test_absolute_colwise(): X, Y = T.matrix(), T.matrix() X.tag.test_value = test_X Y.tag.test_value = test_Y dist = absolute(X, Y).sum(axis=0) f = theano.function([X, Y], dist, mode='FAST_COMPILE') res = f(test_X, test_Y) correct = np.allclose(res, [0.06, 0.08, 0.07]) assert correct, 'absolute loss colwise not working'
def test_absolute(): X, Y = T.matrix(), T.matrix() X.tag.test_value = test_X Y.tag.test_value = test_Y dist = absolute(X, Y).sum() f = theano.function([X, Y], dist, mode='FAST_COMPILE') res = f(test_X, test_Y) print res assert np.allclose(res, 0.21), 'absolute loss not working'
def test_absolute_rowwise(): X, Y = T.matrix(), T.matrix() X.tag.test_value = test_X Y.tag.test_value = test_Y dist = absolute(X, Y).sum(axis=1) f = theano.function([X, Y], dist, mode='FAST_COMPILE') res = f(test_X, test_Y) correct = roughly(res, [0.06, 0.15]) assert correct, 'absolute loss rowwise not working'