示例#1
0
    def architecture(self):
        """ Shows network's architecture in the terminal if
        ``verbose`` parameter is equal to ``True``.
        """
        self.logs.title("Network's architecture")

        values = []
        for index, layer in enumerate(self.layers, start=1):
            input_shape = preformat_layer_shape(layer.input_shape)
            output_shape = preformat_layer_shape(layer.output_shape)
            classname = layer.__class__.__name__

            values.append((index, input_shape, classname, output_shape))

        table.TableBuilder.show_full_table(
            columns=[
                table.Column(name="#"),
                table.Column(name="Input shape"),
                table.Column(name="Layer Type"),
                table.Column(name="Output shape"),
            ],
            values=values,
            stdout=self.logs.write,
        )
        self.logs.newline()
示例#2
0
    def architecture(self):
        """
        Shows network's architecture in the terminal if
        ``verbose`` parameter is equal to ``True``.
        """
        if not is_sequential(self.connection):
            raise TypeError("You can check architecture only for sequential "
                            "connections. For other types of connections it's "
                            "better to use the `neupy.plots.layer_structure` "
                            "function.")

        self.logs.title("Network's architecture")

        values = []
        for index, layer in enumerate(self.layers, start=1):
            input_shape = preformat_layer_shape(layer.input_shape)
            output_shape = preformat_layer_shape(layer.output_shape)
            classname = layer.__class__.__name__

            values.append((index, input_shape, classname, output_shape))

        table.TableBuilder.show_full_table(
            columns=[
                table.Column(name="#"),
                table.Column(name="Input shape"),
                table.Column(name="Layer Type"),
                table.Column(name="Output shape"),
            ],
            values=values,
            stdout=self.logs.write,
        )
        self.logs.newline()
示例#3
0
    def architecture(self):
        """
        Shows network's architecture in the terminal if
        ``verbose`` parameter is equal to ``True``.
        """
        if not is_sequential(self.connection):
            raise TypeError("You can check architecture only for sequential "
                            "connections. For other types of connections it's "
                            "better to use the `neupy.plots.layer_structure` "
                            "function.")

        self.logs.title("Network's architecture")

        values = []
        for index, layer in enumerate(self.layers, start=1):
            input_shape = preformat_layer_shape(layer.input_shape)
            output_shape = preformat_layer_shape(layer.output_shape)
            classname = layer.__class__.__name__

            values.append((index, input_shape, classname, output_shape))

        table.TableBuilder.show_full_table(
            columns=[
                table.Column(name="#"),
                table.Column(name="Input shape"),
                table.Column(name="Layer Type"),
                table.Column(name="Output shape"),
            ],
            values=values,
            stdout=self.logs.write,
        )
        self.logs.newline()
示例#4
0
    def __repr__(self):
        n_layers = len(self)

        if n_layers > 5 or not is_sequential(self):
            return '{} -> [... {} layers ...] -> {}'.format(
                preformat_layer_shape(self.input_shape), n_layers,
                preformat_layer_shape(self.output_shape))

        return ' > '.join([repr(layer) for layer in self])
示例#5
0
文件: base.py 项目: itdxer/neupy
    def __repr__(self):
        n_layers = len(self)

        if n_layers > 5 or not is_sequential(self):
            conn = '{} -> [... {} layers ...] -> {}'.format(
                preformat_layer_shape(self.input_shape),
                n_layers,
                preformat_layer_shape(self.output_shape)
            )
        else:
            conn = ' > '.join([repr(layer) for layer in self])

        return conn
示例#6
0
    def architecture(self):
        """
        Shows network's architecture in the terminal if
        ``verbose`` parameter is equal to ``True``.
        """
        if not is_sequential(self.connection):
            raise TypeError("You can check architecture only for sequential "
                            "connections. For other types of connections "
                            "it's better to use the "
                            "`neupy.plots.network_structure` function.")

        self.logs.title("Network's architecture")

        values = []
        for index, layer in enumerate(self.layers, start=1):
            input_shape = preformat_layer_shape(layer.input_shape)
            output_shape = preformat_layer_shape(layer.output_shape)
            classname = layer.__class__.__name__

            values.append((index, input_shape, classname, output_shape))

        self.logs.table(
            values, headers=['#', 'Input shape', 'Layer type', 'Output shape'])
        self.logs.newline()
示例#7
0
 def test_preformat_layer_shape(self):
     self.assertEqual((2, 3, 1), preformat_layer_shape((2, 3, 1)))
     self.assertEqual(10, preformat_layer_shape((10, )))
示例#8
0
 def test_preformat_layer_shape(self):
     self.assertEqual((2, 3, 1), preformat_layer_shape((2, 3, 1)))
     self.assertEqual(10, preformat_layer_shape((10,)))