当前位置: 首页>>代码示例>>Python>>正文


Python links.Convolution2D方法代码示例

本文整理汇总了Python中chainer.links.Convolution2D方法的典型用法代码示例。如果您正苦于以下问题:Python links.Convolution2D方法的具体用法?Python links.Convolution2D怎么用?Python links.Convolution2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chainer.links的用法示例。


在下文中一共展示了links.Convolution2D方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self, in_channels, out_channels, ksize=3, pad=1, activation=F.leaky_relu, mode='none', bn=False, dr=None):
        super(ResBlock, self).__init__()
        initializer = chainer.initializers.GlorotUniform()
        initializer_sc = chainer.initializers.GlorotUniform()
        self.activation = activation
        self.mode = _downsample if mode == 'down' else _upsample if mode == 'up' else None
        self.learnable_sc = in_channels != out_channels
        self.dr = dr
        self.bn = bn
        with self.init_scope():
            self.c1 = L.Convolution2D(in_channels,  out_channels, ksize=ksize, pad=pad, initialW=initializer, nobias=bn)
            self.c2 = L.Convolution2D(out_channels, out_channels, ksize=ksize, pad=pad, initialW=initializer, nobias=bn)
            if bn:
                self.b1 = L.BatchNormalization(out_channels)
                self.b2 = L.BatchNormalization(out_channels)
            if self.learnable_sc:
                self.c_sc = L.Convolution2D(in_channels, out_channels, ksize=1, pad=0, initialW=initializer_sc) 
开发者ID:pstuvwx,项目名称:Deep_VoiceChanger,代码行数:19,代码来源:block.py

示例2: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self, in_channels, out_channels, ksize=3, pad=1, activation=F.relu, mode='none', bn=True, dr=None):
        super(ResBlock, self).__init__()
        initializer = chainer.initializers.GlorotUniform()
        initializer_sc = chainer.initializers.GlorotUniform()
        self.activation = activation
        self.mode = _downsample if mode == 'down' else _upsample if mode == 'up' else None
        self.learnable_sc = in_channels != out_channels
        self.dr = dr
        self.bn = bn
        with self.init_scope():
            self.c1 = L.Convolution1D(in_channels,  out_channels, ksize=ksize, pad=pad, initialW=initializer, nobias=bn)
            self.c2 = L.Convolution1D(out_channels, out_channels, ksize=ksize, pad=pad, initialW=initializer, nobias=bn)
            if bn:
                self.b1 = L.BatchNormalization(out_channels)
                self.b2 = L.BatchNormalization(out_channels)
            if self.learnable_sc:
                self.c_sc = L.Convolution2D(in_channels, out_channels, ksize=1, pad=0, initialW=initializer_sc) 
开发者ID:pstuvwx,项目名称:Deep_VoiceChanger,代码行数:19,代码来源:block_1d.py

示例3: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self, n_actions, max_episode_steps):
        super().__init__()
        with self.init_scope():
            self.embed = L.EmbedID(max_episode_steps + 1, 3136)
            self.image2hidden = chainerrl.links.Sequence(
                L.Convolution2D(None, 32, 8, stride=4),
                F.relu,
                L.Convolution2D(None, 64, 4, stride=2),
                F.relu,
                L.Convolution2D(None, 64, 3, stride=1),
                functools.partial(F.reshape, shape=(-1, 3136)),
            )
            self.hidden2out = chainerrl.links.Sequence(
                L.Linear(None, 512),
                F.relu,
                L.Linear(None, n_actions),
                DiscreteActionValue,
            ) 
开发者ID:chainer,项目名称:chainerrl,代码行数:20,代码来源:train_dqn_batch_grasping.py

示例4: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self, n_actions, n_input_channels=4,
                 activation=F.relu, bias=0.1):
        self.n_actions = n_actions
        self.n_input_channels = n_input_channels
        self.activation = activation

        super().__init__()
        with self.init_scope():
            self.conv_layers = chainer.ChainList(
                L.Convolution2D(n_input_channels, 32, 8, stride=4,
                                initial_bias=bias),
                L.Convolution2D(32, 64, 4, stride=2, initial_bias=bias),
                L.Convolution2D(64, 64, 3, stride=1, initial_bias=bias))

            self.a_stream = MLP(3136, n_actions, [512])
            self.v_stream = MLP(3136, 1, [512]) 
开发者ID:chainer,项目名称:chainerrl,代码行数:18,代码来源:dueling_dqn.py

示例5: init_like_torch

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def init_like_torch(link):
    # Mimic torch's default parameter initialization
    # TODO(muupan): Use chainer's initializers when it is merged
    for l in link.links():
        if isinstance(l, L.Linear):
            out_channels, in_channels = l.W.shape
            stdv = 1 / np.sqrt(in_channels)
            l.W.array[:] = np.random.uniform(-stdv, stdv, size=l.W.shape)
            if l.b is not None:
                l.b.array[:] = np.random.uniform(-stdv, stdv, size=l.b.shape)
        elif isinstance(l, L.Convolution2D):
            out_channels, in_channels, kh, kw = l.W.shape
            stdv = 1 / np.sqrt(in_channels * kh * kw)
            l.W.array[:] = np.random.uniform(-stdv, stdv, size=l.W.shape)
            if l.b is not None:
                l.b.array[:] = np.random.uniform(-stdv, stdv, size=l.b.shape) 
开发者ID:chainer,项目名称:chainerrl,代码行数:18,代码来源:init_like_torch.py

示例6: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self, n_layers, n_vocab, embed_size, hidden_size, dropout=0.1):
        hidden_size /= 3
        super(CNNEncoder, self).__init__(
            embed=L.EmbedID(n_vocab, embed_size, ignore_label=-1,
                            initialW=embed_init),
            cnn_w3=L.Convolution2D(
                embed_size, hidden_size, ksize=(3, 1), stride=1, pad=(2, 0),
                nobias=True),
            cnn_w4=L.Convolution2D(
                embed_size, hidden_size, ksize=(4, 1), stride=1, pad=(3, 0),
                nobias=True),
            cnn_w5=L.Convolution2D(
                embed_size, hidden_size, ksize=(5, 1), stride=1, pad=(4, 0),
                nobias=True),
            mlp=MLP(n_layers, hidden_size * 3, dropout)
        )
        self.output_size = hidden_size * 3
        self.dropout = dropout 
开发者ID:Pinafore,项目名称:qb,代码行数:20,代码来源:nets.py

示例7: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self):
        super(FCN_32s, self).__init__(
            conv1_1=L.Convolution2D(3, 64, 3, pad=100),
            conv1_2=L.Convolution2D(64, 64, 3),
            conv2_1=L.Convolution2D(64, 128, 3),
            conv2_2=L.Convolution2D(128, 128, 3),
            conv3_1=L.Convolution2D(128, 256, 3),
            conv3_2=L.Convolution2D(256, 256, 3),
            conv4_1=L.Convolution2D(256, 512, 3),
            conv4_2=L.Convolution2D(512, 512, 3),
            conv4_3=L.Convolution2D(512, 512, 3),
            conv5_1=L.Convolution2D(512, 512, 3),
            conv5_2=L.Convolution2D(512, 512, 3),
            conv5_3=L.Convolution2D(512, 512, 3),
            fc6=L.Convolution2D(512, 4096, 7),
            fc7=L.Convolution2D(4096, 4096, 1),
            score_fr=L.Convolution2D(4096, 21, 1),
            upsample=L.Deconvolution2D(21, 21, 64, 32),
        )
        self.train = True 
开发者ID:mitmul,项目名称:ssai-cnn,代码行数:22,代码来源:FCN_32s.py

示例8: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self):
        super(VGG_multi, self).__init__(
            conv1_1=L.Convolution2D(3, 64, 3, stride=1, pad=1),
            conv1_2=L.Convolution2D(64, 64, 3, stride=1, pad=1),

            conv2_1=L.Convolution2D(64, 128, 3, stride=1, pad=1),
            conv2_2=L.Convolution2D(128, 128, 3, stride=1, pad=1),

            conv3_1=L.Convolution2D(128, 256, 3, stride=1, pad=1),
            conv3_2=L.Convolution2D(256, 256, 3, stride=1, pad=1),
            conv3_3=L.Convolution2D(256, 256, 3, stride=1, pad=1),

            conv4_1=L.Convolution2D(256, 512, 3, stride=1, pad=1),
            conv4_2=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            conv4_3=L.Convolution2D(512, 512, 3, stride=1, pad=1),

            conv5_1=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            conv5_2=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            conv5_3=L.Convolution2D(512, 512, 3, stride=1, pad=1),

            fc6=L.Linear(2048, 4096),
            fc7=L.Linear(4096, 4096),
            fc8=L.Linear(4096, 768),
        )
        self.train = True 
开发者ID:mitmul,项目名称:ssai-cnn,代码行数:27,代码来源:VGG_multi.py

示例9: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self):
        super(VGG_single, self).__init__(
            conv1_1=L.Convolution2D(3, 64, 3, stride=1, pad=1),
            conv1_2=L.Convolution2D(64, 64, 3, stride=1, pad=1),

            conv2_1=L.Convolution2D(64, 128, 3, stride=1, pad=1),
            conv2_2=L.Convolution2D(128, 128, 3, stride=1, pad=1),

            conv3_1=L.Convolution2D(128, 256, 3, stride=1, pad=1),
            conv3_2=L.Convolution2D(256, 256, 3, stride=1, pad=1),
            conv3_3=L.Convolution2D(256, 256, 3, stride=1, pad=1),

            conv4_1=L.Convolution2D(256, 512, 3, stride=1, pad=1),
            conv4_2=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            conv4_3=L.Convolution2D(512, 512, 3, stride=1, pad=1),

            conv5_1=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            conv5_2=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            conv5_3=L.Convolution2D(512, 512, 3, stride=1, pad=1),

            fc6=L.Linear(2048, 4096),
            fc7=L.Linear(4096, 4096),
            fc8=L.Linear(4096, 256),
        )
        self.train = True 
开发者ID:mitmul,项目名称:ssai-cnn,代码行数:27,代码来源:VGG_single.py

示例10: init_like_torch

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def init_like_torch(link):
    # Mimic torch's default parameter initialization
    # TODO(muupan): Use chainer's initializers when it is merged
    for l in link.links():
        if isinstance(l, L.Linear):
            out_channels, in_channels = l.W.data.shape
            stdv = 1 / np.sqrt(in_channels)
            l.W.data[:] = np.random.uniform(-stdv, stdv, size=l.W.data.shape)
            if l.b is not None:
                l.b.data[:] = np.random.uniform(-stdv, stdv,
                                                size=l.b.data.shape)
        elif isinstance(l, L.Convolution2D):
            out_channels, in_channels, kh, kw = l.W.data.shape
            stdv = 1 / np.sqrt(in_channels * kh * kw)
            l.W.data[:] = np.random.uniform(-stdv, stdv, size=l.W.data.shape)
            if l.b is not None:
                l.b.data[:] = np.random.uniform(-stdv, stdv,
                                                size=l.b.data.shape) 
开发者ID:muupan,项目名称:async-rl,代码行数:20,代码来源:init_like_torch.py

示例11: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self):
        super(Mix, self).__init__()

        enc_ch = [3, 64, 256, 512, 1024, 2048]
        ins_ch = [6, 128, 384, 640, 2176, 3072]

        self.conv = [None] * 6
        self.bn = [None] * 6
        for i in range(1, 6):
            c = L.Convolution2D(enc_ch[i] + ins_ch[i], enc_ch[i], 1, nobias=True)
            b = L.BatchNormalization(enc_ch[i])

            self.conv[i] = c
            self.bn[i] = b

            self.add_link('c{}'.format(i), c)
            self.add_link('b{}'.format(i), b) 
开发者ID:pfnet-research,项目名称:nips17-adversarial-attack,代码行数:19,代码来源:rec_multibp_resnet.py

示例12: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self, n_class=21):
        self.train=True
        super(FCN32s, self).__init__(
            conv1_1=L.Convolution2D(3, 64, 3, stride=1, pad=100),
            conv1_2=L.Convolution2D(64, 64, 3, stride=1, pad=1),
            conv2_1=L.Convolution2D(64, 128, 3, stride=1, pad=1),
            conv2_2=L.Convolution2D(128, 128, 3, stride=1, pad=1),
            conv3_1=L.Convolution2D(128, 256, 3, stride=1, pad=1),
            conv3_2=L.Convolution2D(256, 256, 3, stride=1, pad=1),
            conv3_3=L.Convolution2D(256, 256, 3, stride=1, pad=1),
            conv4_1=L.Convolution2D(256, 512, 3, stride=1, pad=1),
            conv4_2=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            conv4_3=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            conv5_1=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            conv5_2=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            conv5_3=L.Convolution2D(512, 512, 3, stride=1, pad=1),
            fc6=L.Convolution2D(512, 4096, 7, stride=1, pad=0),
            fc7=L.Convolution2D(4096, 4096, 1, stride=1, pad=0),
            score_fr=L.Convolution2D(4096, n_class, 1, stride=1, pad=0,
                nobias=True, initialW=np.zeros((n_class, 4096, 1, 1))),
            upscore=L.Deconvolution2D(n_class, n_class, 64, stride=32, pad=0,
                nobias=True, initialW=f.bilinear_interpolation_kernel(n_class, n_class, ksize=64)),
        ) 
开发者ID:oyam,项目名称:Semantic-Segmentation-using-Adversarial-Networks,代码行数:25,代码来源:fcn32s.py

示例13: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self, ch):
        super(Link_Convolution2D, self).__init__(L.Convolution2D(None, None))

        # code.InteractiveConsole({'ch': ch}).interact()

        self.ksize = size2d(ch.ksize)
        self.stride = size2d(ch.stride)
        ps = size2d(ch.pad)
        self.pads = ps + ps

        if not (ch.b is None):
            # nobias = True の場合
            self.M = ch.b.shape[0]
            self.b = helper.make_tensor_value_info(
                '/b', TensorProto.FLOAT, [self.M])
        else:
            self.M = "TODO"
            self.b = None

        self.W = helper.make_tensor_value_info(
            '/W', TensorProto.FLOAT,
            [self.M, 'channel_size'] + list(self.ksize)) 
开发者ID:pfnet-research,项目名称:chainer-compiler,代码行数:24,代码来源:links.py

示例14: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self, in_size, ch, out_size, stride=2, groups=1):
        super(BottleNeckA, self).__init__()
        initialW = initializers.HeNormal()

        with self.init_scope():
            self.conv1 = L.Convolution2D(
                in_size, ch, 1, stride, 0, initialW=initialW, nobias=True)
            self.bn1 = L.BatchNormalization(ch)
            self.conv2 = L.Convolution2D(
                ch, ch, 3, 1, 1, initialW=initialW, nobias=True,
                groups=groups)
            self.bn2 = L.BatchNormalization(ch)
            self.conv3 = L.Convolution2D(
                ch, out_size, 1, 1, 0, initialW=initialW, nobias=True)
            self.bn3 = L.BatchNormalization(out_size)

            self.conv4 = L.Convolution2D(
                in_size, out_size, 1, stride, 0,
                initialW=initialW, nobias=True)
            self.bn4 = L.BatchNormalization(out_size) 
开发者ID:pfnet-research,项目名称:chainer-compiler,代码行数:22,代码来源:Resnet_with_loss.py

示例15: __init__

# 需要导入模块: from chainer import links [as 别名]
# 或者: from chainer.links import Convolution2D [as 别名]
def __init__(self, in_channels, out1, proj3, out3, proj5, out5, proj_pool,
                 conv_init=None, bias_init=None):
        super(Inception, self).__init__()
        with self.init_scope():
            self.conv1 = convolution_2d.Convolution2D(
                in_channels, out1, 1, initialW=conv_init,
                initial_bias=bias_init)
            self.proj3 = convolution_2d.Convolution2D(
                in_channels, proj3, 1, initialW=conv_init,
                initial_bias=bias_init)
            self.conv3 = convolution_2d.Convolution2D(
                proj3, out3, 3, pad=1, initialW=conv_init,
                initial_bias=bias_init)
            self.proj5 = convolution_2d.Convolution2D(
                in_channels, proj5, 1, initialW=conv_init,
                initial_bias=bias_init)
            self.conv5 = convolution_2d.Convolution2D(
                proj5, out5, 5, pad=2, initialW=conv_init,
                initial_bias=bias_init)
            self.projp = convolution_2d.Convolution2D(
                in_channels, proj_pool, 1, initialW=conv_init,
                initial_bias=bias_init) 
开发者ID:pfnet-research,项目名称:chainer-compiler,代码行数:24,代码来源:GoogleNet_with_loss.py


注:本文中的chainer.links.Convolution2D方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。