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


Python transforms.Rectlin方法代码示例

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


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

示例1: conv_params

# 需要导入模块: from neon import transforms [as 别名]
# 或者: from neon.transforms import Rectlin [as 别名]
def conv_params(fsize, nfm, stride=1, relu=True):
    return dict(fshape=(fsize, fsize, nfm), strides=stride, padding=(1 if fsize > 1 else 0),
                activation=(Rectlin() if relu else None),
                init=Kaiming(local=True),
                batch_norm=True) 
开发者ID:NervanaSystems,项目名称:ModelZoo,代码行数:7,代码来源:resnet_cifar10.py

示例2: module_factory

# 需要导入模块: from neon import transforms [as 别名]
# 或者: from neon.transforms import Rectlin [as 别名]
def module_factory(nfm, stride=1):
    mainpath = [Conv(**conv_params(3, nfm, stride=stride)),
                Conv(**conv_params(3, nfm, relu=False))]
    sidepath = [SkipNode() if stride == 1 else Conv(**id_params(nfm))]
    module = [MergeSum([mainpath, sidepath]),
              Activation(Rectlin())]
    return module

# Structure of the deep residual part of the network:
# args.depth modules of 2 convolutional layers each at feature map depths of 16, 32, 64 
开发者ID:NervanaSystems,项目名称:ModelZoo,代码行数:12,代码来源:resnet_cifar10.py

示例3: module_factory

# 需要导入模块: from neon import transforms [as 别名]
# 或者: from neon.transforms import Rectlin [as 别名]
def module_factory(nfm, stride=1):
    projection = None if stride == 1 else IdentityInit()
    module = [Conv(**conv_params(3, nfm, stride=stride)),
              Conv(**conv_params(3, nfm, relu=False))]
    module = module if args.network == 'plain' else [ResidualModule(module, projection)]
    module.append(Activation(Rectlin()))
    return module


# Structure of the deep residual part of the network:
# args.depth modules of 2 convolutional layers each at feature map depths of 16, 32, 64 
开发者ID:NervanaSystems,项目名称:ModelZoo,代码行数:13,代码来源:miniplaces_msra.py

示例4: create_network

# 需要导入模块: from neon import transforms [as 别名]
# 或者: from neon.transforms import Rectlin [as 别名]
def create_network():
    init = Kaiming()
    padding = dict(pad_d=1, pad_h=1, pad_w=1)
    strides = dict(str_d=2, str_h=2, str_w=2)
    dilation = dict(dil_d=2, dil_h=2, dil_w=2)
    common = dict(init=init, batch_norm=True, activation=Rectlin())
    layers = [
        Conv((9, 9, 9, 16), padding=padding, strides=strides, init=init, activation=Rectlin()),
        Conv((5, 5, 5, 32), dilation=dilation, **common),
        Conv((3, 3, 3, 64), dilation=dilation, **common),
        Pooling((2, 2, 2), padding=padding, strides=strides),
        Conv((2, 2, 2, 128), **common),
        Conv((2, 2, 2, 128), **common),
        Conv((2, 2, 2, 128), **common),
        Conv((2, 2, 2, 256), **common),
        Conv((2, 2, 2, 1024), **common),
        Conv((2, 2, 2, 4096), **common),
        Conv((2, 2, 2, 2048), **common),
        Conv((2, 2, 2, 1024), **common),
        Dropout(),
        Affine(2, init=Kaiming(local=False), batch_norm=True, activation=Softmax())
    ]
    return Model(layers=layers)


# Parse the command line arguments 
开发者ID:anlthms,项目名称:dsb-2017,代码行数:28,代码来源:run.py

示例5: _create_layer

# 需要导入模块: from neon import transforms [as 别名]
# 或者: from neon.transforms import Rectlin [as 别名]
def _create_layer(self):
        """ Build a network consistent with the DeepMind Nature paper. """
        _logger.debug("Output shape = %d" % self.output_shape)
        # create network
        init_norm = Gaussian(loc=0.0, scale=0.01)
        layers = []
        # The first hidden layer convolves 32 filters of 8x8 with stride 4 with the input image and applies a rectifier nonlinearity.
        layers.append(
                Conv((8, 8, 32),
                strides=4,
                init=init_norm,
                activation=Rectlin(),
                batch_norm=self.batch_norm))
        # The second hidden layer convolves 64 filters of 4x4 with stride 2, again followed by a rectifier nonlinearity.
        layers.append(
                Conv((4, 4, 64),
                strides=2,
                init=init_norm,
                activation=Rectlin(),
                batch_norm=self.batch_norm))
        # This is followed by a third convolutional layer that convolves 64 filters of 3x3 with stride 1 followed by a rectifier.
        layers.append(
                Conv((3, 3, 64),
                strides=1,
                init=init_norm,
                activation=Rectlin(),
                batch_norm=self.batch_norm))
        # The final hidden layer is fully-connected and consists of 512 rectifier units.
        layers.append(
                Affine(
                    nout=512,
                    init=init_norm,
                    activation=Rectlin(),
                    batch_norm=self.batch_norm))
        # The output layer is a fully-connected linear layer with a single output for each valid action.
        layers.append(
                Affine(
                    nout= self.output_shape,
                    init = init_norm))
        return layers 
开发者ID:cowhi,项目名称:deepatari,代码行数:42,代码来源:dqnneon.py

示例6: gen_model

# 需要导入模块: from neon import transforms [as 别名]
# 或者: from neon.transforms import Rectlin [as 别名]
def gen_model(num_channels, height, width):
    assert NervanaObject.be is not None, 'need to generate a backend before using this function'

    init_uni = Kaiming()

    # we have 1 issue, they have bias layers we don't allow batchnorm and biases
    conv_common = dict(padding=1, init=init_uni, activation=Rectlin(), batch_norm=True)

    # set up the layers
    layers = []

    # need to store a ref to the pooling layers to pass
    # to the upsampling layers to get the argmax indicies
    # for upsampling, this stack holds the pooling layer refs
    pool_layers = []

    # first loop generates the encoder layers
    nchan = [64, 128, 256, 512, 512]
    for ind in range(len(nchan)):
        nchanu = nchan[ind]
        lrng = 2 if ind <= 1 else 3
        for lind in range(lrng):
            nm = 'conv%d_%d' % (ind+1, lind+1)
            layers.append(Conv((3, 3, nchanu), strides=1, name=nm, **conv_common))

        layers.append(Pooling(2, strides=2, name='conv%d_pool' % ind))
        pool_layers.append(layers[-1])
        if ind >= 2:
            layers.append(Dropout(keep=0.5, name='drop%d' % (ind+1)))

    # this loop generates the decoder layers
    for ind in range(len(nchan)-1,-1,-1):
        nchanu = nchan[ind]
        lrng = 2 if ind <= 1 else 3
        # upsampling layers need a ref to the corresponding pooling layer
        # to access the argmx indices for upsampling
        layers.append(Upsampling(2, pool_layers.pop(), strides=2, padding=0,
                      name='conv%d_unpool' % ind))
        for lind in range(lrng):
            nm = 'deconv%d_%d' % (ind+1, lind+1)
            if ind < 4 and lind == lrng-1:
                nchanu = nchan[ind]/2
            layers.append(Conv((3, 3, nchanu), strides=1, name=nm, **conv_common))
            if ind == 0:
                break
        if ind >= 2:
            layers.append(Dropout(keep=0.5, name='drop%d' % (ind+1)))

    # last conv layer outputs 12 channels, 1 for each output class
    # with a pixelwise softmax over the channels
    act_last = PixelwiseSoftmax(num_channels, height, width, name="PixelwiseSoftmax")
    conv_last = dict(padding=1, init=init_uni, activation=act_last, batch_norm=False)
    layers.append(Conv((3, 3, num_channels), strides=1, name='deconv_out', **conv_last))
    return layers 
开发者ID:NervanaSystems,项目名称:neon_segnet,代码行数:56,代码来源:segnet_neon.py


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