def test_grad_keep_type(self):
"""Tests that the theano grad method returns a list if it is passed a list
and a single variable if it is passed a single variable.
pylearn2 depends on theano behaving this way. This functionality has been
added three times and erroneously removed twice. If you do anything that
requires changing this test or making it fail you are almost certainly
making a common mistake, NOT fixing something. """
X = tensor.matrix()
y = X.sum()
G = tensor.grad(y, [X])
assert isinstance(G, list)
G = tensor.grad(y, X)
assert not isinstance(G, list)
评论列表
文章目录