提交 27c008d0 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #3652 from nouiz/err_msg

Better error message.
......@@ -484,7 +484,7 @@ Using the GPU
The first thing you'll need for Theano to use your GPU is Nvidia's
GPU-programming toolchain. You should install at least the CUDA driver and the CUDA Toolkit, as
`described here <http://www.nvidia.com/object/cuda_get.html>`_. The CUDA
`described here <https://developer.nvidia.com/cuda-toolkit>`_. The CUDA
Toolkit installs a folder on your computer with subfolders *bin*, *lib*,
*include*, and some more too. (Sanity check: The *bin* subfolder should contain an *nvcc*
program which is the compiler for GPU code.) This folder is called the *cuda
......
......@@ -4230,7 +4230,8 @@ def get_vector_length(v):
"""
v = as_tensor_variable(v)
if v.ndim != 1:
raise TypeError('argument must be symbolic vector')
raise TypeError("argument must be symbolic vector, got '%s'" %
v)
if v.type.broadcastable[0]:
return 1
if isinstance(v, gof.Constant) and v.type.ndim == 1:
......@@ -4479,6 +4480,11 @@ class Reshape(Op):
def reshape(x, newshape, ndim=None, name=None):
if ndim is None:
newshape = as_tensor_variable(newshape)
if newshape.ndim != 1:
raise TypeError(
"New shape in reshape must be a vector or a list/tuple of"
" scalar. Got %s after conversion to a vector." % newshape)
try:
ndim = get_vector_length(newshape)
except ValueError:
......
......@@ -379,10 +379,18 @@ def _infer_ndim_bcast(ndim, shape, *args):
ndim = template.ndim
else:
v_shape = tensor.as_tensor_variable(shape)
if v_shape.ndim != 1:
raise TypeError(
"shape must be a vector or list of scalar, got '%s'" % v_shape)
if ndim is None:
ndim = tensor.get_vector_length(v_shape)
bcast = [False] * ndim
if v_shape.ndim != 1:
raise TypeError("shape must be a vector or list of scalar, got '%s'" %
v_shape)
if (not (v_shape.dtype.startswith('int') or
v_shape.dtype.startswith('uint'))):
raise TypeError('shape must be an integer vector or list',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论