Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String representation for network #3

Merged
merged 3 commits into from
Jul 6, 2015
Merged

String representation for network #3

merged 3 commits into from
Jul 6, 2015

Conversation

sidps
Copy link
Contributor

@sidps sidps commented Jul 6, 2015

Based on Lasagne PR #324

A string representation for a Neural Network built using Lasagne. The network topology is represented using adjacency lists (currently). Listing incoming and outgoing layers for each layer in the network is optional.

Examples:
(1) A network with sequential structure: input --> dense --> dropout --> dense --> dropout --> dense

>>> print(get_network_str(output_layer))

Layer    Description                                              
-----    -----------                                              
0        <lasagne.layers.input.InputLayer object at 0x1004f1110>  
1        <lasagne.layers.dense.DenseLayer object at 0x104c86510>  
2        <lasagne.layers.noise.DropoutLayer object at 0x104c86550>
3        <lasagne.layers.dense.DenseLayer object at 0x104ca1550>  
4        <lasagne.layers.noise.DropoutLayer object at 0x104ca1590>
5        <lasagne.layers.dense.DenseLayer object at 0x104ca1810>  

(2) A network with two branches: input --> conv1, conv2 --> pool1, pool2 --> dense1, dense2 --> concat --> output

>>> print(get_network_str(output_layer, incomings=True, outgoings=True))

or

>>> layers = get_all_layers(output_layer)
>>> print(get_network_str(layers, get_network=False, incomings=True, outgoings=True))

In -->     Layer    --> Out    Description                                               
-------    -----    -------    -----------                                               
[]         0        [1, 4]     <lasagne.layers.input.InputLayer object at 0x104ca1810>   
[0]        1        [2]        <lasagne.layers.conv.Conv2DLayer object at 0x104c86550>   
[1]        2        [3]        <lasagne.layers.pool.MaxPool2DLayer object at 0x104c86510>
[2]        3        [7]        <lasagne.layers.dense.DenseLayer object at 0x104d5ec10>   
[0]        4        [5]        <lasagne.layers.conv.Conv2DLayer object at 0x104d5ec50>   
[4]        5        [6]        <lasagne.layers.pool.MaxPool2DLayer object at 0x104d5eed0>
[5]        6        [7]        <lasagne.layers.dense.DenseLayer object at 0x104d6e190>   
[3, 6]     7        [8]        <lasagne.layers.merge.ConcatLayer object at 0x104d6e1d0>  
[7]        8        []         <lasagne.layers.dense.DenseLayer object at 0x104d6e450>   

Overriding __str__ for each Layer class can change the default description of each layer.

For something prettier, there's the draw_net tool. (See Lasagne PR #174)

@ebenolson
Copy link
Member

Great, our first utility function! Thank you.

ebenolson added a commit that referenced this pull request Jul 6, 2015
String representation for network
@ebenolson ebenolson merged commit 788a4cb into Lasagne:master Jul 6, 2015
@sidps sidps deleted the strutil branch July 6, 2015 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants