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


Python NeuralNet.initialize_layers方法代码示例

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


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

示例1: test_diamond

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
    def test_diamond(self, NeuralNet):
        input, hidden1, hidden2, concat, output = (
            Mock(), Mock(), Mock(), Mock(), Mock())
        nn = NeuralNet(
            layers=[
                ('input', input),
                ('hidden1', hidden1),
                ('hidden2', hidden2),
                ('concat', concat),
                ('output', output),
                ],
            input_shape=(10, 10),
            hidden2_incoming='input',
            concat_incoming=['hidden1', 'hidden2'],
            )
        nn.initialize_layers(nn.layers)

        input.assert_called_with(name='input', shape=(10, 10))
        hidden1.assert_called_with(incoming=input.return_value, name='hidden1')
        hidden2.assert_called_with(incoming=input.return_value, name='hidden2')
        concat.assert_called_with(
            incoming=[hidden1.return_value, hidden2.return_value],
            name='concat'
            )
        output.assert_called_with(incoming=concat.return_value, name='output')
开发者ID:alobrix,项目名称:Deep-Learning,代码行数:27,代码来源:test_lasagne.py

示例2: test_diamond

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
    def test_diamond(self, NeuralNet):
        input = Mock(__name__='InputLayer', __bases__=(InputLayer,))
        hidden1, hidden2, concat, output = [
            Mock(__name__='MockLayer', __bases__=(Layer,)) for i in range(4)]
        nn = NeuralNet(
            layers=[
                ('input', input),
                ('hidden1', hidden1),
                ('hidden2', hidden2),
                ('concat', concat),
                ('output', output),
                ],
            input_shape=(10, 10),
            hidden2_incoming='input',
            concat_incomings=['hidden1', 'hidden2'],
            )
        nn.initialize_layers(nn.layers)

        input.assert_called_with(name='input', shape=(10, 10))
        hidden1.assert_called_with(incoming=input.return_value, name='hidden1')
        hidden2.assert_called_with(incoming=input.return_value, name='hidden2')
        concat.assert_called_with(
            incomings=[hidden1.return_value, hidden2.return_value],
            name='concat'
            )
        output.assert_called_with(incoming=concat.return_value, name='output')
开发者ID:dnouri,项目名称:nolearn,代码行数:28,代码来源:test_base.py

示例3: test_initialization_legacy_with_unicode_names

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
 def test_initialization_legacy_with_unicode_names(self, NeuralNet):
     # Test whether legacy initialization is triggered; if not,
     # raises error.
     input = Mock(__name__="InputLayer", __bases__=(InputLayer,))
     hidden1, hidden2, output = [Mock(__name__="MockLayer", __bases__=(Layer,)) for i in range(3)]
     nn = NeuralNet(
         layers=[(u"input", input), (u"hidden1", hidden1), (u"hidden2", hidden2), (u"output", output)],
         input_shape=(10, 10),
         hidden1_some="param",
     )
     nn.initialize_layers()
开发者ID:buyijie,项目名称:nolearn,代码行数:13,代码来源:test_base.py

示例4: test_initialization_with_mask_input

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
 def test_initialization_with_mask_input(self, NeuralNet):
     nn = NeuralNet(
         layers=[
             (InputLayer, {'shape': (None, 20, 32), 'name': 'l_in'}),
             (InputLayer, {'shape': (None, 20), 'name': 'l_mask'}),
             (RecurrentLayer, {'incoming': 'l_in',
                               'mask_input': 'l_mask',
                               'num_units': 2,
                               'name': 'l_rec'}),
             ])
     nn.initialize_layers()
     assert nn.layers_['l_rec'].mask_incoming_index == 1
开发者ID:dnouri,项目名称:nolearn,代码行数:14,代码来源:test_base.py

示例5: test_initialization_legacy

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
    def test_initialization_legacy(self, NeuralNet):
        input = Mock(__name__='InputLayer', __bases__=(InputLayer,))
        hidden1, hidden2, output = [
            Mock(__name__='MockLayer', __bases__=(Layer,)) for i in range(3)]
        nn = NeuralNet(
            layers=[
                ('input', input),
                ('hidden1', hidden1),
                ('hidden2', hidden2),
                ('output', output),
                ],
            input_shape=(10, 10),
            hidden1_some='param',
            )
        out = nn.initialize_layers(nn.layers)

        input.assert_called_with(
            name='input', shape=(10, 10))
        assert nn.layers_['input'] is input.return_value

        hidden1.assert_called_with(
            incoming=input.return_value, name='hidden1', some='param')
        assert nn.layers_['hidden1'] is hidden1.return_value

        hidden2.assert_called_with(
            incoming=hidden1.return_value, name='hidden2')
        assert nn.layers_['hidden2'] is hidden2.return_value

        output.assert_called_with(
            incoming=hidden2.return_value, name='output')

        assert out[0] is nn.layers_['output']
开发者ID:dnouri,项目名称:nolearn,代码行数:34,代码来源:test_base.py

示例6: test_initialization_with_tuples

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
    def test_initialization_with_tuples(self, NeuralNet):
        input = Mock(__name__='InputLayer', __bases__=(InputLayer,))
        hidden1, hidden2, output = [
            Mock(__name__='MockLayer', __bases__=(Layer,)) for i in range(3)]
        nn = NeuralNet(
            layers=[
                (input, {'shape': (10, 10), 'name': 'input'}),
                (hidden1, {'some': 'param', 'another': 'param'}),
                (hidden2, {}),
                (output, {'name': 'output'}),
                ],
            input_shape=(10, 10),
            mock1_some='iwin',
            )
        out = nn.initialize_layers(nn.layers)

        input.assert_called_with(
            name='input', shape=(10, 10))
        assert nn.layers_['input'] is input.return_value

        hidden1.assert_called_with(
            incoming=input.return_value, name='mock1',
            some='iwin', another='param')
        assert nn.layers_['mock1'] is hidden1.return_value

        hidden2.assert_called_with(
            incoming=hidden1.return_value, name='mock2')
        assert nn.layers_['mock2'] is hidden2.return_value

        output.assert_called_with(
            incoming=hidden2.return_value, name='output')

        assert out[0] is nn.layers_['output']
开发者ID:dnouri,项目名称:nolearn,代码行数:35,代码来源:test_base.py

示例7: test_initialization_legacy

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
    def test_initialization_legacy(self, NeuralNet):
        input, hidden1, hidden2, output = Mock(), Mock(), Mock(), Mock()
        nn = NeuralNet(
            layers=[
                ('input', input),
                ('hidden1', hidden1),
                ('hidden2', hidden2),
                ('output', output),
                ],
            input_shape=(10, 10),
            hidden1_some='param',
            )
        out = nn.initialize_layers(nn.layers)

        input.assert_called_with(
            name='input', shape=(10, 10))
        nn.layers_['input'] is input.return_value

        hidden1.assert_called_with(
            incoming=input.return_value, name='hidden1', some='param')
        nn.layers_['hidden1'] is hidden1.return_value

        hidden2.assert_called_with(
            incoming=hidden1.return_value, name='hidden2')
        nn.layers_['hidden2'] is hidden2.return_value

        output.assert_called_with(
            incoming=hidden2.return_value, name='output')

        assert out is nn.layers_['output']
开发者ID:alobrix,项目名称:Deep-Learning,代码行数:32,代码来源:test_lasagne.py

示例8: test_initialization_with_layer_instance

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
 def test_initialization_with_layer_instance(self, NeuralNet):
     layer1 = InputLayer(shape=(128, 13))  # name will be assigned
     layer2 = DenseLayer(layer1, name='output', num_units=2)  # has name
     nn = NeuralNet(layers=layer2)
     out = nn.initialize_layers()
     assert nn.layers_['output'] == layer2 == out[0]
     assert nn.layers_['input0'] == layer1
开发者ID:dnouri,项目名称:nolearn,代码行数:9,代码来源:test_base.py

示例9: test_initialization_with_tuples

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
    def test_initialization_with_tuples(self, NeuralNet):
        input = Mock(__name__="InputLayer", __bases__=(InputLayer,))
        hidden1, hidden2, output = [Mock(__name__="MockLayer", __bases__=(Layer,)) for i in range(3)]
        nn = NeuralNet(
            layers=[
                (input, {"shape": (10, 10), "name": "input"}),
                (hidden1, {"some": "param", "another": "param"}),
                (hidden2, {}),
                (output, {"name": "output"}),
            ],
            input_shape=(10, 10),
            mock1_some="iwin",
        )
        out = nn.initialize_layers(nn.layers)

        input.assert_called_with(name="input", shape=(10, 10))
        assert nn.layers_["input"] is input.return_value

        hidden1.assert_called_with(incoming=input.return_value, name="mock1", some="iwin", another="param")
        assert nn.layers_["mock1"] is hidden1.return_value

        hidden2.assert_called_with(incoming=hidden1.return_value, name="mock2")
        assert nn.layers_["mock2"] is hidden2.return_value

        output.assert_called_with(incoming=hidden2.return_value, name="output")

        assert out is nn.layers_["output"]
开发者ID:buyijie,项目名称:nolearn,代码行数:29,代码来源:test_base.py

示例10: test_initialization

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
    def test_initialization(self, NeuralNet):
        input, hidden1, hidden2, output = Mock(), Mock(), Mock(), Mock()
        nn = NeuralNet(
            layers=[
                (input, {'shape': (10, 10), 'name': 'input'}),
                (hidden1, {'some': 'param', 'another': 'param'}),
                (hidden2, {}),
                (output, {'name': 'output'}),
                ],
            input_shape=(10, 10),
            mock1_some='iwin',
            )
        out = nn.initialize_layers(nn.layers)

        input.assert_called_with(
            name='input', shape=(10, 10))
        nn.layers_['input'] is input.return_value

        hidden1.assert_called_with(
            incoming=input.return_value, name='mock1',
            some='iwin', another='param')
        nn.layers_['mock1'] is hidden1.return_value

        hidden2.assert_called_with(
            incoming=hidden1.return_value, name='mock2')
        nn.layers_['mock2'] is hidden2.return_value

        output.assert_called_with(
            incoming=hidden2.return_value, name='output')

        assert out is nn.layers_['output']
开发者ID:alobrix,项目名称:Deep-Learning,代码行数:33,代码来源:test_lasagne.py

示例11: test_initialization_legacy_with_unicode_names

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
 def test_initialization_legacy_with_unicode_names(self, NeuralNet):
     # Test whether legacy initialization is triggered; if not,
     # raises error.
     input = Mock(__name__='InputLayer', __bases__=(InputLayer,))
     hidden1, hidden2, output = [
         Mock(__name__='MockLayer', __bases__=(Layer,)) for i in range(3)]
     nn = NeuralNet(
         layers=[
             (u'input', input),
             (u'hidden1', hidden1),
             (u'hidden2', hidden2),
             (u'output', output),
             ],
         input_shape=(10, 10),
         hidden1_some='param',
         )
     nn.initialize_layers()
开发者ID:dnouri,项目名称:nolearn,代码行数:19,代码来源:test_base.py

示例12: test_initializtion_with_tuples_resolve_layers

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
 def test_initializtion_with_tuples_resolve_layers(self, NeuralNet):
     nn = NeuralNet(
         layers=[
             ('lasagne.layers.InputLayer', {'shape': (None, 10)}),
             ('lasagne.layers.DenseLayer', {'num_units': 33}),
             ],
         )
     out, = nn.initialize_layers(nn.layers)
     assert out.num_units == 33
开发者ID:dnouri,项目名称:nolearn,代码行数:11,代码来源:test_base.py

示例13: test_legacy_initialization_with_mask_input

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
 def test_legacy_initialization_with_mask_input(self, NeuralNet):
     nn = NeuralNet(
         layers=[
             ('l_in', InputLayer),
             ('l_mask', InputLayer),
             ('l_rec', RecurrentLayer),
             ],
         l_in_shape=(None, 20, 32),
         l_in_name='l_in',
         l_mask_shape=(None, 20),
         l_mask_name='l_mask',
         l_rec_incoming='l_in',
         l_rec_mask_input='l_mask',
         l_rec_num_units=2,
         l_rec_name='l_rec',
         )
     nn.initialize_layers()
     assert nn.layers_['l_rec'].mask_incoming_index == 1
开发者ID:dnouri,项目名称:nolearn,代码行数:20,代码来源:test_base.py

示例14: test_initializtion_legacy_resolve_layers

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
 def test_initializtion_legacy_resolve_layers(self, NeuralNet):
     nn = NeuralNet(
         layers=[
             ('input', 'lasagne.layers.InputLayer'),
             ('output', 'lasagne.layers.DenseLayer'),
             ],
         input_shape=(None, 10),
         output_num_units=33,
         )
     out, = nn.initialize_layers(nn.layers)
     assert out.num_units == 33
开发者ID:dnouri,项目名称:nolearn,代码行数:13,代码来源:test_base.py

示例15: test_diamond

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import initialize_layers [as 别名]
    def test_diamond(self, NeuralNet):
        input = Mock(__name__="InputLayer", __bases__=(InputLayer,))
        hidden1, hidden2, concat, output = [Mock(__name__="MockLayer", __bases__=(Layer,)) for i in range(4)]
        nn = NeuralNet(
            layers=[
                ("input", input),
                ("hidden1", hidden1),
                ("hidden2", hidden2),
                ("concat", concat),
                ("output", output),
            ],
            input_shape=(10, 10),
            hidden2_incoming="input",
            concat_incomings=["hidden1", "hidden2"],
        )
        nn.initialize_layers(nn.layers)

        input.assert_called_with(name="input", shape=(10, 10))
        hidden1.assert_called_with(incoming=input.return_value, name="hidden1")
        hidden2.assert_called_with(incoming=input.return_value, name="hidden2")
        concat.assert_called_with(incomings=[hidden1.return_value, hidden2.return_value], name="concat")
        output.assert_called_with(incoming=concat.return_value, name="output")
开发者ID:buyijie,项目名称:nolearn,代码行数:24,代码来源:test_base.py


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