Created
October 16, 2016 13:44
-
-
Save jiqiujia/0b86c05a5c871ca5feb2a7b1c51059bb to your computer and use it in GitHub Desktop.
util function using lasagne
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def architecture_string(layer): | |
model_arch = '' | |
for i, layer in enumerate(lasagne.layers.get_all_layers(layer)): | |
name = string.ljust(layer.__class__.__name__, 28) | |
model_arch += " %2i %s %s " % (i, name, | |
lasagne.layers.get_output_shape(layer)) | |
if hasattr(layer, 'filter_size'): | |
model_arch += str(layer.filter_size[0]) | |
model_arch += ' //' | |
elif hasattr(layer, 'pool_size'): | |
if isinstance(layer.pool_size, int): | |
model_arch += str(layer.pool_size) | |
else: | |
model_arch += str(layer.pool_size[0]) | |
model_arch += ' //' | |
if hasattr(layer, 'p'): | |
model_arch += ' [%.2f]' % layer.p | |
if hasattr(layer, 'stride'): | |
model_arch += str(layer.stride[0]) | |
if hasattr(layer, 'learning_rate_scale'): | |
if layer.learning_rate_scale != 1.0: | |
model_arch += ' [lr_scale=%.2f]' % layer.learning_rate_scale | |
if hasattr(layer, 'params'): | |
for param in layer.params: | |
if 'trainable' not in layer.params[param]: | |
model_arch += ' [NT] ' | |
model_arch += '\n' | |
return model_arch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment