提交 5c28147a authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Explicitly use 'axis' parameter in more calls to min, max, etc.

上级 235b6d99
...@@ -50,7 +50,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias(): ...@@ -50,7 +50,7 @@ def test_GpuCrossentropySoftmaxArgmax1HotWithBias():
dot_value = numpy.asarray(numpy.dot(xx, W_values),dtype='float32') dot_value = numpy.asarray(numpy.dot(xx, W_values),dtype='float32')
p_y_given_x = T.nnet.softmax(dot_result+b) p_y_given_x = T.nnet.softmax(dot_result+b)
y_pred = T.argmax(p_y_given_x) y_pred = T.argmax(p_y_given_x, axis=-1)
loss = -T.mean(T.log(p_y_given_x)[T.arange(y.shape[0]), y]) loss = -T.mean(T.log(p_y_given_x)[T.arange(y.shape[0]), y])
dW = T.grad(loss,W) dW = T.grad(loss,W)
classify = theano.function( inputs = [x,y,b,W,dot_result], outputs = [loss,y_pred,dW], classify = theano.function( inputs = [x,y,b,W,dot_result], outputs = [loss,y_pred,dW],
......
...@@ -808,7 +808,9 @@ def test_argmax_pushdown(): ...@@ -808,7 +808,9 @@ def test_argmax_pushdown():
x = tensor.dmatrix() x = tensor.dmatrix()
#test that the max_and_argmax is pushed down if the max is not used #test that the max_and_argmax is pushed down if the max is not used
out = tensor.max_and_argmax(softmax(tensor.exp(tensor.tanh(sigmoid(x)))))[1] out = tensor.max_and_argmax(
softmax(tensor.exp(tensor.tanh(sigmoid(x)))),
axis=-1)[1]
env = gof.Env( env = gof.Env(
[x], [x],
[out]) [out])
...@@ -824,7 +826,9 @@ def test_argmax_pushdown(): ...@@ -824,7 +826,9 @@ def test_argmax_pushdown():
assert str(env.toposort()[1].op) == 'OutputGuard' assert str(env.toposort()[1].op) == 'OutputGuard'
x = tensor.dmatrix() x = tensor.dmatrix()
#test that the max_and_argmax is not pushed down if the max is used #test that the max_and_argmax is not pushed down if the max is used
out = tensor.max_and_argmax(softmax(tensor.exp(tensor.tanh(sigmoid(x)))))[0] out = tensor.max_and_argmax(
softmax(tensor.exp(tensor.tanh(sigmoid(x)))),
axis=-1)[0]
env = gof.Env( env = gof.Env(
[x], [x],
[out]) [out])
...@@ -847,7 +851,7 @@ def test_argmax_pushdown_bias(): ...@@ -847,7 +851,7 @@ def test_argmax_pushdown_bias():
x = tensor.dmatrix() x = tensor.dmatrix()
b = tensor.dvector() b = tensor.dvector()
out = tensor.argmax(softmax_with_bias(x, b)) out = tensor.argmax(softmax_with_bias(x, b), axis=-1)
env = gof.Env( env = gof.Env(
[x,b], [x,b],
[out]) [out])
...@@ -867,7 +871,7 @@ def test_argmax_pushdown_bias(): ...@@ -867,7 +871,7 @@ def test_argmax_pushdown_bias():
x = tensor.dmatrix() x = tensor.dmatrix()
b = tensor.dvector() b = tensor.dvector()
out = tensor.max_and_argmax(softmax_with_bias(x, b))[0] out = tensor.max_and_argmax(softmax_with_bias(x, b), axis=-1)[0]
env = gof.Env( env = gof.Env(
[x,b], [x,b],
[out]) [out])
......
...@@ -122,7 +122,11 @@ class TestDownsampleFactorMax(unittest.TestCase): ...@@ -122,7 +122,11 @@ class TestDownsampleFactorMax(unittest.TestCase):
c_val = function([images], c)(imval) c_val = function([images], c)(imval)
g = tensor.grad(c, images) g = tensor.grad(c, images)
g_val = function([images], [g.shape, tensor.min(tensor.min(tensor.min(g))), tensor.max(tensor.max(tensor.max(g)))])(imval) g_val = function([images],
[g.shape,
tensor.min(g, axis=(0,1,2)),
tensor.max(g, axis=(0,1,2))]
)(imval)
#removed as already tested in test_max_pool_2d_2D #removed as already tested in test_max_pool_2d_2D
#This make test in debug mode too slow. #This make test in debug mode too slow.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论