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


Python ConstructionWrapper.create方法代码示例

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


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

示例1: FullyConnected

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def FullyConnected(size=None, activation='rel', name=None):
    """Create a Fully Connected (inner product) layer."""
    if size is None:
        return ConstructionWrapper.create(FullyConnectedLayerImpl, name=name,
                                          activation=activation)
    else:
        return ConstructionWrapper.create(FullyConnectedLayerImpl, size=size,
                                          name=name, activation=activation)
开发者ID:IDSIA,项目名称:brainstorm,代码行数:10,代码来源:fully_connected_layer.py

示例2: test_get_layer_description

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def test_get_layer_description():
    l = ConstructionWrapper.create('FooLayerImpl', name='foo')
    l2 = ConstructionWrapper.create('FooLayerImpl', name='bar')
    l3 = ConstructionWrapper.create('FooLayerImpl', name='baz')
    _ = l >> l2
    _ = l >> l3
    descr = get_layer_description(l.layer)
    assert descr == {
        '@type': 'Foo',
        '@outgoing_connections': {
            'default': ['bar.default', 'baz.default']
        }
    }
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:15,代码来源:test_generate_architecture.py

示例3: test_get_layer_description_named_inputs_outputs

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def test_get_layer_description_named_inputs_outputs():
    l = ConstructionWrapper.create('FooLayerImpl', name='foo')
    l2 = ConstructionWrapper.create('FooLayerImpl', name='bar')
    l3 = ConstructionWrapper.create('FooLayerImpl', name='baz')
    _ = l - 'out1' >> l2
    _ = l >> 'A' - l3
    descr = get_layer_description(l.layer)
    assert descr == {
        '@type': 'Foo',
        '@outgoing_connections': {
            'default': ['baz.A'],
            'out1': ['bar.default']
        }
    }
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:16,代码来源:test_generate_architecture.py

示例4: CTC

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def CTC(name=None):
    """Create a CTC layer which integrates a softmax loss function and the CTC algorithm.

    Applies the softmax activation function on 'default' input and puts
    results (per-class probabilities) in 'predictions'. It then takes sequence labels
    from the 'targets' input and uses them to compute the CTC loss, which is stored in
    the 'loss' output (indexed by sequence, but not by time). Suitable deltas are
    computed and backpropagated towards the 'default' input.

    Note that the labels must be
    - in the range 1 ... # of classes *inclusive*. 0 may not be used as a label since 
      it stands for the CTC 'blank' node.
    - of the size (time, batchsize, 1). This is a technical requirement of brainstorm.
      Where the label sequence is shorter, zeros are to be used for padding the time axis.

    Consequently, the layer size passed to the function bs.tools.get_in_out_layers_for_ctc
    (if you create your system that way) must be # of classes + 1.

    IMPORTANT WARNING:
        This layer currently considers the input data mask to be boolean (i.e. no
        weights are allowed), and it should have the form 1 ... 1 0 ... 0 (only the final
        unbroken sequence of zeros is removed)

    WARNING:
        This layer does not compute derivatives wrt the 'targets' input.
        It also does not use the deltas coming in from the 'predictions'.
    """
    return ConstructionWrapper.create(CTCLayerImpl, name=name)
开发者ID:michaelwand,项目名称:brainstorm,代码行数:30,代码来源:ctc_layer.py

示例5: Elementwise

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def Elementwise(activation='rel', name=None):
    """Create an Elementwise layer.

    This layer just applies a unit-wise function to its inputs.
    """
    return ConstructionWrapper.create(ElementwiseLayerImpl, name=name,
                                      activation=activation)
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:9,代码来源:elementwise_layer.py

示例6: Input

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def Input(out_shapes):
    """Create an Input layer.
    Special input layer type, that provides access to external data.

    The 'out_shapes' keyword argument is required and specifies the names and
    shapes of all external inputs.
    """
    return ConstructionWrapper.create(InputLayerImpl, out_shapes=out_shapes)
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:10,代码来源:input_layer.py

示例7: test_layer_with_kwargs

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def test_layer_with_kwargs():
    l = ConstructionWrapper.create('FooLayerImpl', name='foo', a=2, b=3)
    descr = get_layer_description(l.layer)
    assert descr == {
        '@type': 'Foo',
        '@outgoing_connections': {},
        'a': 2,
        'b': 3
    }
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:11,代码来源:test_generate_architecture.py

示例8: Convolution2D

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def Convolution2D(num_filters, kernel_size, stride=(1, 1), padding=0,
                  activation='rel', name=None):
    """Create a 2D Convolution layer."""
    return ConstructionWrapper.create(Convolution2DLayerImpl,
                                      num_filters=num_filters,
                                      kernel_size=kernel_size,
                                      stride=stride,
                                      padding=padding,
                                      activation=activation,
                                      name=name)
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:12,代码来源:convolution_layer_2d.py

示例9: BatchNorm

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def BatchNorm(name=None, decay=0.9, epsilon=1.0e-5):
    """Create a BatchNormalization layer.

    This layer implements batch normalization over the last (right-most)
    dimension. Thus, it can be use with both fully connected and convolutional
    layers (but only with data in NHWC format).
    """
    return ConstructionWrapper.create(BatchNormLayerImpl,
                                      name=name,
                                      decay=decay,
                                      epsilon=epsilon)
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:13,代码来源:batch_normalization_layer.py

示例10: DeltasScaling

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def DeltasScaling(factor, name=None):
    """Create an DeltasScaling layer.

    This layer does nothing on the forward pass, but scales the deltas flowing
    back during the backward pass by a given factor.

    This can be used to invert the deltas and set up an adversarial branch of
    the network.
    """
    return ConstructionWrapper.create(DeltasScalingLayerImpl, name=name,
                                      factor=factor)
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:13,代码来源:deltas_scaling_layer.py

示例11: test_generate_architecture

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def test_generate_architecture():
    l1 = ConstructionWrapper.create('InputLayerImpl')
    l2 = ConstructionWrapper.create('FooLayerImpl', name='bar')
    l3 = ConstructionWrapper.create('FooLayerImpl', name='baz')
    l4 = ConstructionWrapper.create('FooLayerImpl', name='out')
    _ = l1 - 'foo' >> l2 >> 'A' - l4
    _ = l1 - 'bar' >> l3 >> 'B' - l4

    arch1 = generate_architecture(l1.layer)
    arch2 = generate_architecture(l2.layer)
    arch3 = generate_architecture(l3.layer)
    assert arch1 == arch2
    assert arch1 == arch3
    assert arch1 == {
        'Input': {
            '@type': 'Input',
            '@outgoing_connections': {
                'foo': ['bar.default'],
                'bar': ['baz.default'],
            }

        },
        'bar': {
            '@type': 'Foo',
            '@outgoing_connections': {
                'default': ['out.A'],
            }
        },
        'baz': {
            '@type': 'Foo',
            '@outgoing_connections': {
                'default': ['out.B'],
            }
        },
        'out': {
            '@type': 'Foo',
            '@outgoing_connections': {}
        }
    }
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:41,代码来源:test_generate_architecture.py

示例12: SigmoidCE

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def SigmoidCE(name=None):
    """Create a sigmoid layer with integrated Binomial Cross Entropy loss.

    Applies the sigmoid activation function on 'default' input and puts the
    results (per-label probabilities) in 'probabilities'.

    It also takes as 'targets' a binary vector and computes the binomial
    cross-entropy loss. The resulting losses are stored in the 'loss' output.

    WARNING:
        This layer does not compute derivatives wrt the 'targets' input.
        It also does not use the deltas coming in from the 'probabilities'.
    """
    return ConstructionWrapper.create(SigmoidCELayerImpl, name=name)
开发者ID:nagyistoce,项目名称:dnn-brainstorm,代码行数:16,代码来源:sigmoid_ce_layer.py

示例13: BinomialCrossEntropy

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def BinomialCrossEntropy(name=None):
    """Create a Binomial Cross Entropy Layer.

    Calculate the Binomial Cross Entropy between outputs and **binary** targets

    Cross entropy is by definition asymmetric, therefore the inputs are named
    'default' for the network outputs and 'targets' for the binary targets.
    This layer only calculates the deltas for the default inputs.
    Also note that this implementation only works for **binary** targets and
    outputs in the range 0 to 1.
    For outputs outside that range or non-binary targets the result is
    undefined.
    """
    return ConstructionWrapper.create(BinomialCrossEntropyLayerImpl,
                                      name=name)
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:17,代码来源:binomial_cross_entropy_layer.py

示例14: SquaredError

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def SquaredError(name=None):
    """
    Create a SquaredError layer which computes half of the squared difference
    between the inputs `default` and `targets` element-wise. The factor of half
    is used to be consistent with common machine learning texts and resources.

    Produces outputs named `predictions` and `loss`. The `loss` output can be
    connected to a ``Loss`` layer for typical network training for a
    regression task.

    This layer acts similar to ``SigmoidCE`` and ``SoftmaxCE`` layers. Like
    the above layers, it does not compute the gradients w.r.t. the `targets`
    input and ignores incoming deltas w.r.t. the `predictions` output.
    """
    return ConstructionWrapper.create(SquaredErrorLayerImpl, name=name)
开发者ID:AdityoSanjaya,项目名称:brainstorm,代码行数:17,代码来源:squared_error_layer.py

示例15: SoftmaxFiddle

# 需要导入模块: from brainstorm.structure.construction import ConstructionWrapper [as 别名]
# 或者: from brainstorm.structure.construction.ConstructionWrapper import create [as 别名]
def SoftmaxFiddle(name=None):
    """Create a softmax layer with integrated Multinomial Cross Entropy loss.

    Applies the softmax activation function on 'default' input and puts
    results (per-class probabilities) in 'predictions'.

    It also takes 'targets' as input (typically a one-hot vector),
    and computes the multinomial cross-entropy loss. The resulting losses are
    stored in the 'loss' output.

    For pixel/voxel-wise classification, the `channel` dimension must be
    right-most (known as NHWC or NDHWC format).

    WARNING:
        This layer does not compute derivatives wrt the 'targets' input.
        It also does not use the deltas coming in from the 'predictions'.
    """
    return ConstructionWrapper.create(SoftmaxFiddleLayerImpl, name=name)
开发者ID:NASCENCE,项目名称:brainstorm,代码行数:20,代码来源:softmax_fiddle_layer.py


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