提交 b79e5f2a authored 作者: amrithasuresh's avatar amrithasuresh

1. Delete import numpy

2. Updated numpy as np
上级 0784ab7b
...@@ -17,7 +17,6 @@ from theano.gof import Apply, Op ...@@ -17,7 +17,6 @@ from theano.gof import Apply, Op
from six.moves import xrange from six.moves import xrange
import warnings import warnings
import numpy
import numpy as np import numpy as np
try: try:
...@@ -69,7 +68,7 @@ def get_conv_output_shape(image_shape, kernel_shape, ...@@ -69,7 +68,7 @@ def get_conv_output_shape(image_shape, kernel_shape,
nkern, kshp = kernel_shape[0], kernel_shape[2:] nkern, kshp = kernel_shape[0], kernel_shape[2:]
if filter_dilation is None: if filter_dilation is None:
filter_dilation = numpy.ones(len(subsample), dtype='int') filter_dilation = np.ones(len(subsample), dtype='int')
if isinstance(border_mode, tuple): if isinstance(border_mode, tuple):
out_shp = tuple(get_conv_shape_1axis( out_shp = tuple(get_conv_shape_1axis(
...@@ -181,7 +180,7 @@ def get_conv_gradweights_shape(image_shape, top_shape, ...@@ -181,7 +180,7 @@ def get_conv_gradweights_shape(image_shape, top_shape,
nchan, topshp = top_shape[1], top_shape[2:] nchan, topshp = top_shape[1], top_shape[2:]
if filter_dilation is None: if filter_dilation is None:
filter_dilation = numpy.ones(len(subsample), dtype='int') filter_dilation = np.ones(len(subsample), dtype='int')
if isinstance(border_mode, tuple): if isinstance(border_mode, tuple):
out_shp = tuple(get_conv_gradweights_shape_1axis( out_shp = tuple(get_conv_gradweights_shape_1axis(
...@@ -286,7 +285,7 @@ def get_conv_gradinputs_shape(kernel_shape, top_shape, ...@@ -286,7 +285,7 @@ def get_conv_gradinputs_shape(kernel_shape, top_shape,
nkern, kshp = kernel_shape[1], kernel_shape[2:] nkern, kshp = kernel_shape[1], kernel_shape[2:]
if filter_dilation is None: if filter_dilation is None:
filter_dilation = numpy.ones(len(subsample), dtype='int') filter_dilation = np.ones(len(subsample), dtype='int')
if isinstance(border_mode, tuple): if isinstance(border_mode, tuple):
out_shp = tuple(get_conv_gradinputs_shape_1axis( out_shp = tuple(get_conv_gradinputs_shape_1axis(
...@@ -1508,11 +1507,11 @@ class BaseAbstractConv(Op): ...@@ -1508,11 +1507,11 @@ class BaseAbstractConv(Op):
out_shape = get_conv_output_shape(img.shape, kern.shape, out_shape = get_conv_output_shape(img.shape, kern.shape,
mode, [1] * self.convdim, dilation) mode, [1] * self.convdim, dilation)
out = numpy.zeros(out_shape, dtype=img.dtype) out = np.zeros(out_shape, dtype=img.dtype)
dil_kern_shp = kern.shape[:-self.convdim] + tuple( dil_kern_shp = kern.shape[:-self.convdim] + tuple(
(kern.shape[-self.convdim + i] - 1) * dilation[i] + 1 (kern.shape[-self.convdim + i] - 1) * dilation[i] + 1
for i in range(self.convdim)) for i in range(self.convdim))
dilated_kern = numpy.zeros(dil_kern_shp, dtype=kern.dtype) dilated_kern = np.zeros(dil_kern_shp, dtype=kern.dtype)
dilated_kern[(slice(None), slice(None)) + dilated_kern[(slice(None), slice(None)) +
tuple(slice(None, None, dilation[i]) for i in range(self.convdim)) tuple(slice(None, None, dilation[i]) for i in range(self.convdim))
] = kern ] = kern
...@@ -1522,7 +1521,7 @@ class BaseAbstractConv(Op): ...@@ -1522,7 +1521,7 @@ class BaseAbstractConv(Op):
bval = _bvalfromboundary('fill') bval = _bvalfromboundary('fill')
with warnings.catch_warnings(): with warnings.catch_warnings():
warnings.simplefilter('ignore', numpy.ComplexWarning) warnings.simplefilter('ignore', np.ComplexWarning)
for b in xrange(img.shape[0]): for b in xrange(img.shape[0]):
for n in xrange(kern.shape[0]): for n in xrange(kern.shape[0]):
for im0 in xrange(img.shape[1]): for im0 in xrange(img.shape[1]):
...@@ -1592,8 +1591,8 @@ class AbstractConv(BaseAbstractConv): ...@@ -1592,8 +1591,8 @@ class AbstractConv(BaseAbstractConv):
def perform(self, node, inp, out_): def perform(self, node, inp, out_):
img, kern = inp img, kern = inp
img = numpy.asarray(img) img = np.asarray(img)
kern = numpy.asarray(kern) kern = np.asarray(kern)
dil_kernshp = tuple((kern.shape[2 + i] - 1) * self.filter_dilation[i] + 1 dil_kernshp = tuple((kern.shape[2 + i] - 1) * self.filter_dilation[i] + 1
for i in range(self.convdim)) for i in range(self.convdim))
o, = out_ o, = out_
...@@ -1613,7 +1612,7 @@ class AbstractConv(BaseAbstractConv): ...@@ -1613,7 +1612,7 @@ class AbstractConv(BaseAbstractConv):
if isinstance(mode, tuple): if isinstance(mode, tuple):
pad = tuple(int(mode[i]) for i in range(self.convdim)) pad = tuple(int(mode[i]) for i in range(self.convdim))
mode = "valid" mode = "valid"
new_img = numpy.zeros((img.shape[0], img.shape[1]) + new_img = np.zeros((img.shape[0], img.shape[1]) +
tuple(img.shape[i + 2] + 2 * pad[i] tuple(img.shape[i + 2] + 2 * pad[i]
for i in range(self.convdim)), for i in range(self.convdim)),
dtype=img.dtype) dtype=img.dtype)
...@@ -1809,8 +1808,8 @@ class AbstractConv_gradWeights(BaseAbstractConv): ...@@ -1809,8 +1808,8 @@ class AbstractConv_gradWeights(BaseAbstractConv):
def perform(self, node, inp, out_): def perform(self, node, inp, out_):
img, topgrad, shape = inp img, topgrad, shape = inp
img = numpy.asarray(img) img = np.asarray(img)
topgrad = numpy.asarray(topgrad) topgrad = np.asarray(topgrad)
o, = out_ o, = out_
...@@ -1833,7 +1832,7 @@ class AbstractConv_gradWeights(BaseAbstractConv): ...@@ -1833,7 +1832,7 @@ class AbstractConv_gradWeights(BaseAbstractConv):
pad = tuple(int(mode[i]) for i in range(self.convdim)) pad = tuple(int(mode[i]) for i in range(self.convdim))
mode = "valid" mode = "valid"
new_img = numpy.zeros((img.shape[0], img.shape[1]) + new_img = np.zeros((img.shape[0], img.shape[1]) +
tuple(img.shape[i + 2] + 2 * pad[i] tuple(img.shape[i + 2] + 2 * pad[i]
for i in range(self.convdim)), for i in range(self.convdim)),
dtype=img.dtype) dtype=img.dtype)
...@@ -1846,7 +1845,7 @@ class AbstractConv_gradWeights(BaseAbstractConv): ...@@ -1846,7 +1845,7 @@ class AbstractConv_gradWeights(BaseAbstractConv):
new_shape = ((topgrad.shape[0], topgrad.shape[1]) + new_shape = ((topgrad.shape[0], topgrad.shape[1]) +
tuple(img.shape[i + 2] - dil_shape[i] + 1 tuple(img.shape[i + 2] - dil_shape[i] + 1
for i in range(self.convdim))) for i in range(self.convdim)))
new_topgrad = numpy.zeros((new_shape), dtype=topgrad.dtype) new_topgrad = np.zeros((new_shape), dtype=topgrad.dtype)
new_topgrad[(slice(None), slice(None)) + new_topgrad[(slice(None), slice(None)) +
tuple(slice(None, None, self.subsample[i]) tuple(slice(None, None, self.subsample[i])
for i in range(self.convdim))] = topgrad for i in range(self.convdim))] = topgrad
...@@ -2049,8 +2048,8 @@ class AbstractConv_gradInputs(BaseAbstractConv): ...@@ -2049,8 +2048,8 @@ class AbstractConv_gradInputs(BaseAbstractConv):
def perform(self, node, inp, out_): def perform(self, node, inp, out_):
kern, topgrad, shape = inp kern, topgrad, shape = inp
kern = numpy.asarray(kern) kern = np.asarray(kern)
topgrad = numpy.asarray(topgrad) topgrad = np.asarray(topgrad)
o, = out_ o, = out_
mode = self.border_mode mode = self.border_mode
...@@ -2089,7 +2088,7 @@ class AbstractConv_gradInputs(BaseAbstractConv): ...@@ -2089,7 +2088,7 @@ class AbstractConv_gradInputs(BaseAbstractConv):
new_shape = ((topgrad.shape[0], topgrad.shape[1]) + new_shape = ((topgrad.shape[0], topgrad.shape[1]) +
tuple(shape[i] + 2 * pad[i] - dil_kernshp[i] + 1 tuple(shape[i] + 2 * pad[i] - dil_kernshp[i] + 1
for i in range(self.convdim))) for i in range(self.convdim)))
new_topgrad = numpy.zeros((new_shape), dtype=topgrad.dtype) new_topgrad = np.zeros((new_shape), dtype=topgrad.dtype)
new_topgrad[(slice(None), slice(None)) + new_topgrad[(slice(None), slice(None)) +
tuple(slice(None, None, self.subsample[i]) tuple(slice(None, None, self.subsample[i])
for i in range(self.convdim))] = topgrad for i in range(self.convdim))] = topgrad
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论