本文整理汇总了Python中chainer.functions.deconvolution_2d方法的典型用法代码示例。如果您正苦于以下问题:Python functions.deconvolution_2d方法的具体用法?Python functions.deconvolution_2d怎么用?Python functions.deconvolution_2d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chainer.functions
的用法示例。
在下文中一共展示了functions.deconvolution_2d方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: check_forward_consistency_regression
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def check_forward_consistency_regression(self, backend_config):
inputs = self.generate_inputs()
if self.nobias:
x, W = inputs
b = None
else:
x, W, b = inputs
x = chainer.Variable(backend_config.get_array(x))
W = chainer.Variable(backend_config.get_array(W))
if b is not None:
b = chainer.Variable(backend_config.get_array(b))
use_cudnn = backend_config.use_cudnn
with chainer.using_config('use_cudnn', use_cudnn):
y_nd = F.deconvolution_nd(x, W, b, stride=self.stride,
pad=self.pad, outsize=self.outsize,
dilate=self.dilate)
y_2d = F.deconvolution_2d(x, W, b, stride=self.stride,
pad=self.pad, outsize=self.outsize,
dilate=self.dilate)
testing.assert_allclose(
y_nd.array, y_2d.array, **self.check_forward_options)
示例2: forward_expected
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def forward_expected(self, inputs):
"""
Current forward_expected implementation depends on
F.deconvolution_2d itself and thus it's only capable
of checking consistency between backends, not absolute
correctness of computations
"""
if self.nobias:
x, W = inputs
b = None
else:
x, W, b = inputs
y_expected = F.deconvolution_2d(
x, W, b, stride=self.stride, pad=self.pad,
outsize=self.outsize, dilate=self.dilate,
groups=self.groups)
return y_expected.array,
示例3: scale_layer
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def scale_layer(self, feature_map, node):
input_data = node.inputs[0].data
_, _, in_height, in_width = input_data.shape
_, _, feature_height, feature_width = feature_map.shape
kernel_height = in_height + 2 * node.ph - node.sy * (feature_height - 1)
kernel_width = in_width + 2 * node.pw - node.sx * (feature_width - 1)
scaled_feature = F.deconvolution_2d(
feature_map,
self.xp.ones((1, 1, kernel_height, kernel_width)),
stride=(node.sy, node.sx),
pad=(node.ph, node.pw),
outsize=(in_height, in_width),
)
averaged_feature_map = F.average(input_data, axis=1, keepdims=True)
feature_map = scaled_feature * averaged_feature_map
return feature_map
示例4: gen_convtranspose_bn
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def gen_convtranspose_bn(test_name):
gb = onnx_script.GraphBuilder(test_name)
bsize = 2
ichan = 3
ochan = 4
ksize = 3
isize = 7
x = aranges(bsize, ochan, isize, isize)
w = aranges(ochan, ichan, ksize, ksize) * 0.01
scale = aranges(ichan) * 0.1 + 1
bias = aranges(ichan) * 0.1 + 2
mean = aranges(ichan) * 0.1 + 3
var = aranges(ichan) * 0.1 + 4
conv = F.deconvolution_2d(x, w, pad=1, outsize=(isize, isize))
y = F.fixed_batch_normalization(conv, scale, bias, mean, var)
x_v = gb.input('x', x)
w_v = gb.param('w', w)
scale_v = gb.param('scale', scale)
bias_v = gb.param('bias', bias)
mean_v = gb.param('mean', mean)
var_v = gb.param('var', var)
conv_v = gb.ConvTranspose([x_v, w_v],
kernel_shape=[ksize, ksize],
pads=[1, 1, 1, 1],
output_shape=[isize, isize])
y_v = gb.BatchNormalization([conv_v, scale_v, bias_v, mean_v, var_v])
gb.output(y_v, y)
gb.gen_test()
示例5: forward_expected
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def forward_expected(self, link, inputs):
x, = inputs
W = link.W
if self.nobias:
y = F.deconvolution_2d(
x, W,
stride=self.stride, pad=self.pad,
dilate=self.dilate, groups=self.groups)
else:
b = link.b
y = F.deconvolution_2d(
x, W, b,
stride=self.stride, pad=self.pad,
dilate=self.dilate, groups=self.groups)
return y.array,
示例6: forward
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def forward(self, inputs, device):
if self.nobias:
x, W = inputs
b = None
else:
x, W, b = inputs
y = F.deconvolution_2d(
x, W, b, stride=self.stride, pad=self.pad,
outsize=self.outsize, dilate=self.dilate,
groups=self.groups)
return y,
示例7: check_invalid_dilation
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def check_invalid_dilation(self, x_data, w_data):
x = chainer.Variable(x_data)
w = chainer.Variable(w_data)
F.deconvolution_2d(x, w, dilate=self.dilate)
示例8: backward_convolution
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def backward_convolution(x_in, x, l):
y = F.deconvolution_2d(x, l.W, None, l.stride, l.pad, (x_in.data.shape[2], x_in.data.shape[3]))
return y
示例9: backward_convolution
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def backward_convolution(x_in, x, l):
y = F.deconvolution_2d(x, l.W, None, l.stride, l.pad, None)#(x_in.data.shape[2], x_in.data.shape[3]))
return y
示例10: test_forward1
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def test_forward1(self):
n, c_i, c_o = 10, 1, 3
h_i, w_i = 5, 10
h_k, w_k = 10, 10
h_p, w_p = 5, 5
s_y, s_x = 5, 5
x = np.random.uniform(0, 1, (n, c_i, h_i, w_i)).astype(np.float32)
W = np.random.uniform(0, 1, (c_i, c_o, h_k, w_k)).astype(np.float32)
b = np.random.uniform(0, 1, c_o).astype(np.float32)
expected = CF.deconvolution_2d(x, W, b, stride=(s_y, s_x),
pad=(h_p, w_p))
y = F.deconv2d(x, W, b, stride=(s_y, s_x), pad=(h_p, w_p))
self.assertTrue(array_allclose(expected.data, y.data))
示例11: test_forward2
# 需要导入模块: from chainer import functions [as 别名]
# 或者: from chainer.functions import deconvolution_2d [as 别名]
def test_forward2(self):
n, c_i, c_o = 10, 1, 3
h_i, w_i = 5, 10
h_k, w_k = 10, 10
h_p, w_p = 5, 5
s_y, s_x = 5, 5
x = np.random.uniform(0, 1, (n, c_i, h_i, w_i)).astype(np.float32)
W = np.random.uniform(0, 1, (c_i, c_o, h_k, w_k)).astype(np.float32)
b = None
expected = CF.deconvolution_2d(x, W, b, stride=(s_y, s_x),
pad=(h_p, w_p))
y = F.deconv2d(x, W, b, stride=(s_y, s_x), pad=(h_p, w_p))
self.assertTrue(array_allclose(expected.data, y.data))