return T.vector(name=name, dtype=dtype)
elif ndim == 2:
return T.matrix(name=name, dtype=dtype)
elif ndim == 3:
return T.tensor3(name=name, dtype=dtype)
elif ndim == 4:
return T.tensor4(name=name, dtype=dtype)
else:
raise Exception("ndim too large: " + str(ndim))
def shape(x):
"""Return the shape of a tensor.
After Change
raise Exception("Specify either a shape or ndim value.")
if shape is not None:
ndim = len(shape)
broadcast = (False,) * ndim
return T.TensorType(dtype, broadcast)(name)