提交 ba833bb1 authored 作者: Frédéric Bastien's avatar Frédéric Bastien

Merge pull request #1415 from nouiz/py3

fix tests/crash on python 3
...@@ -258,8 +258,9 @@ def run_conv_nnet2(use_gpu): # pretend we are training LeNet for MNIST ...@@ -258,8 +258,9 @@ def run_conv_nnet2(use_gpu): # pretend we are training LeNet for MNIST
logical_hid_shape = tcn.blas.GpuConv.logical_output_shape_2d(tuple( logical_hid_shape = tcn.blas.GpuConv.logical_output_shape_2d(tuple(
shape_img[2:]), tuple(shape_kern[2:]), 'valid') shape_img[2:]), tuple(shape_kern[2:]), 'valid')
logical_hid_shape1 = tcn.blas.GpuConv.logical_output_shape_2d(( logical_hid_shape1 = tcn.blas.GpuConv.logical_output_shape_2d(
logical_hid_shape[0]/2, logical_hid_shape[1]/2), tuple(shape_kern1[2:]), 'valid') (logical_hid_shape[0] // 2, logical_hid_shape[1] // 2),
tuple(shape_kern1[2:]), 'valid')
n_hid = n_kern1 * logical_hid_shape1[0] * logical_hid_shape1[1] n_hid = n_kern1 * logical_hid_shape1[0] * logical_hid_shape1[1]
n_out = 10 n_out = 10
...@@ -342,10 +343,11 @@ def build_conv_nnet2_classif(use_gpu, isize, ksize, n_batch, ...@@ -342,10 +343,11 @@ def build_conv_nnet2_classif(use_gpu, isize, ksize, n_batch,
n_kern1 = 30 # 16 were used in LeNet5 n_kern1 = 30 # 16 were used in LeNet5
shape_kern1 = (n_kern1, n_kern, ksize, ksize) shape_kern1 = (n_kern1, n_kern, ksize, ksize)
logical_hid_shape = tcn.blas.GpuConv.logical_output_shape_2d(( logical_hid_shape = tcn.blas.GpuConv.logical_output_shape_2d(
isize1, isize2), (ksize, ksize), 'valid') (isize1, isize2), (ksize, ksize), 'valid')
logical_hid_shape1 = tcn.blas.GpuConv.logical_output_shape_2d((logical_hid_shape[0]/2, logical_hid_shape1 = tcn.blas.GpuConv.logical_output_shape_2d(
logical_hid_shape[1]/2), (ksize, ksize), 'valid') (logical_hid_shape[0] // 2, logical_hid_shape[1] // 2),
(ksize, ksize), 'valid')
n_hid = n_kern1 * logical_hid_shape1[0] * logical_hid_shape1[1] n_hid = n_kern1 * logical_hid_shape1[0] * logical_hid_shape1[1]
n_out = 10 n_out = 10
......
...@@ -763,7 +763,7 @@ class MRG_RandomStreams(object): ...@@ -763,7 +763,7 @@ class MRG_RandomStreams(object):
# these *SHOULD NEVER BE USED AS FLOATS* # these *SHOULD NEVER BE USED AS FLOATS*
tmp_float_buf = numpy.frombuffer(rstates.data, dtype='float32') tmp_float_buf = numpy.frombuffer(rstates.data, dtype='float32')
assert tmp_float_buf.shape == rstates.shape assert tmp_float_buf.shape == rstates.shape
assert tmp_float_buf.data[:24] == rstates.data[:24] assert (tmp_float_buf.view('int32') == rstates).all()
# transfer to device # transfer to device
node_rstate = float32_shared_constructor(tmp_float_buf) node_rstate = float32_shared_constructor(tmp_float_buf)
assert isinstance(node_rstate.type, CudaNdarrayType) assert isinstance(node_rstate.type, CudaNdarrayType)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论