Skip to content

Commit

Permalink
Truncate keras summary at 10k characters
Browse files Browse the repository at this point in the history
  • Loading branch information
blaiszik committed Jul 25, 2019
1 parent 87e55df commit aaab524
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions dlhub_sdk/models/servables/keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from dlhub_sdk.utils.types import compose_argument_block

_keras_version_tuple = tuple(int(i) for i in keras_version.split("."))

_summary_limit = 10000

def _detect_backend(output):
"""Add the backend
Expand Down Expand Up @@ -82,13 +82,16 @@ def create_model(cls, model_path, output_names=None, arch_path=None,
if output_names is not None:
output['servable']['methods']['run']['method_details']['classes'] = output_names

# Get a full description of the model
# Get a full description of the model. Limit summary to _summary_limit in length
output.summary = ""

def capture_summary(x):
output.summary += x + "\n"

model.summary(print_fn=capture_summary)
output.summary = (output.summary[:_summary_limit] + '<<TRUNCATED>>') \
if len(output.summary) > _summary_limit else output.summary

output['servable']['model_summary'] = output.summary
output['servable']['model_type'] = 'Deep NN'

Expand Down

0 comments on commit aaab524

Please sign in to comment.