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