提交 652f8394 authored 作者: Frederic Bastien's avatar Frederic Bastien

added assert to give better error msg.

上级 31f3394b
...@@ -622,7 +622,12 @@ class MRG_RandomStreams(object): ...@@ -622,7 +622,12 @@ class MRG_RandomStreams(object):
If the size argument is ambiguous on the number of dimensions, If the size argument is ambiguous on the number of dimensions,
ndim may be a plain integer to supplement the missing ndim may be a plain integer to supplement the missing
information. information.
Currently size can't be None. Otherwise it fail later. So I added the assert
""" """
assert isinstance(size, tuple), "size must be a tuple"
assert all([isinstance(i,int) for i in size])
if nstreams is None: if nstreams is None:
nstreams = self.n_streams(size) nstreams = self.n_streams(size)
if self.use_cuda and dtype=='float32': if self.use_cuda and dtype=='float32':
...@@ -664,6 +669,8 @@ class MRG_RandomStreams(object): ...@@ -664,6 +669,8 @@ class MRG_RandomStreams(object):
# second half our U2's. See Wikipedia page: # second half our U2's. See Wikipedia page:
# http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform # http://en.wikipedia.org/wiki/Box%E2%80%93Muller_transform
assert isinstance(size, tuple), "size must be a tuple"
assert all([isinstance(i,int) for i in size])
n_samples = numpy.prod(size) n_samples = numpy.prod(size)
evened = False evened = False
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论