Skip to content

Commit

Permalink
changeable print_summary (#2761)
Browse files Browse the repository at this point in the history
* use changeable print_summary

* minor
  • Loading branch information
Xingdi (Eric) Yuan authored and fchollet committed May 19, 2016
1 parent e2fb8b2 commit 2f8acfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions keras/engine/topology.py
Expand Up @@ -2400,7 +2400,7 @@ def to_yaml(self, **kwargs):
import yaml
return yaml.dump(self._updated_config(), **kwargs)

def summary(self):
def summary(self, line_length=100, positions=[.33, .55, .67, 1.]):
from keras.utils.layer_utils import print_summary

if hasattr(self, 'flattened_layers'):
Expand All @@ -2409,7 +2409,7 @@ def summary(self):
else:
flattened_layers = self.layers

print_summary(flattened_layers, getattr(self, 'container_nodes', None))
print_summary(flattened_layers, getattr(self, 'container_nodes', None), line_length=line_length, positions=positions)


def get_source_inputs(tensor, layer=None, node_index=None):
Expand Down
8 changes: 5 additions & 3 deletions keras/utils/layer_utils.py
Expand Up @@ -35,9 +35,11 @@ def layer_from_config(config, custom_objects={}):
return layer_class.from_config(config['config'])


def print_summary(layers, relevant_nodes=None):
line_length = 100 # total length of printed lines
positions = [35, 55, 67, 100] # absolute positions of log elements in each line
def print_summary(layers, relevant_nodes=None, line_length=100, positions=[.33, .55, .67, 1.]):
# line_length: total length of printed lines
# positions: relative or absolute positions of log elements in each line
if positions[-1] <= 1:
positions = [int(line_length * p) for p in positions]
# header names for the different log elements
to_display = ['Layer (type)', 'Output Shape', 'Param #', 'Connected to']

Expand Down

0 comments on commit 2f8acfe

Please sign in to comment.