當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。