You are using a version of Tean that is too old. In fact, tensor_var.nonzero () is not in any released version. You need to update the development version.
In the development version, I have the following:
>>> that[~(that>=5).nonzero()].max().eval() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: bad operand type for unary ~: 'tuple'
This is because there is no bracket in your line. Here is a nice line:
>>> that[(~(that>=5)).nonzero()].max().eval() array(9, dtype=int32)
But we still have an unexpected result! The problem is that Theano does not support bool. Performing ~ on int8, performs bitwise inversion of 8 bits, not 1 bit. It gives the following result:
>>> (that>=5).eval() array([0, 0, 0, 0, 0, 1, 1, 1, 1, 1], dtype=int8) >>> (~(that>=5)).eval() array([-1, -1, -1, -1, -1, -2, -2, -2, -2, -2], dtype=int8)
You can remove ~ with this:
>>> that[(that<5).nonzero()].max().eval() array(4, dtype=int32)