def test_is_sequential_connection(self): connection1 = layers.join( layers.Input(10), layers.Sigmoid(5), layers.Sigmoid(1), ) self.assertTrue(is_sequential(connection1)) layer = layers.Input(10) self.assertTrue(is_sequential(layer))
def test_is_sequential_partial_connection(self): connection_2 = layers.Input(10) > layers.Sigmoid(5) connection_31 = connection_2 > layers.Sigmoid(1) connection_32 = connection_2 > layers.Sigmoid(2) concatenate = layers.Concatenate() connection_4 = connection_31 > concatenate connection_4 = connection_32 > concatenate self.assertFalse(is_sequential(connection_4)) self.assertTrue(is_sequential(connection_31)) self.assertTrue(is_sequential(connection_32))
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()
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()