Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
New "Large Graph" page for models
Browse files Browse the repository at this point in the history
Gives a roundabout solution to #71
  • Loading branch information
lukeyeager committed Apr 24, 2015
1 parent e73c350 commit 583804b
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
11 changes: 11 additions & 0 deletions digits/model/images/classification/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,17 @@ def show(job):
"""
return render_template('models/images/classification/show.html', job=job)

@app.route(NAMESPACE + '/large_graph', methods=['GET'])
def image_classification_model_large_graph():
"""
Show the loss/accuracy graph, but bigger
"""
job = scheduler.get_job(request.args['job_id'])
if not job:
abort(404)

return render_template('models/images/classification/large_graph.html', job=job)

@app.route(NAMESPACE + '/classify_one', methods=['POST'])
def image_classification_model_classify_one():
"""
Expand Down
18 changes: 15 additions & 3 deletions digits/model/tasks/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,9 @@ def get_labels(self):
def lr_graph_data(self):
"""
Returns learning rate data formatted for a C3.js graph
Keyword arguments:
"""
if not self.train_outputs or 'epoch' not in self.train_outputs or 'learning_rate' not in self.train_outputs:
return None
Expand Down Expand Up @@ -421,9 +424,12 @@ def accuracy_graph_data(self):
else:
return data

def combined_graph_data(self):
def combined_graph_data(self, cull=True):
"""
Returns all train/val outputs in data for one C3.js graph
Keyword arguments:
cull -- if True, cut down the number of data points returned to a reasonable size
"""
data = {
'columns': [],
Expand All @@ -434,7 +440,10 @@ def combined_graph_data(self):

if self.train_outputs and 'epoch' in self.train_outputs:
added_column = False
stride = max(len(self.train_outputs['epoch'].data)/100,1)
if cull:
stride = max(len(self.train_outputs['epoch'].data)/100,1)
else:
stride = 1
for name, output in self.train_outputs.iteritems():
if name not in ['epoch', 'learning_rate']:
col_id = '%s-train' % name
Expand All @@ -451,7 +460,10 @@ def combined_graph_data(self):

if self.val_outputs and 'epoch' in self.val_outputs:
added_column = False
stride = max(len(self.val_outputs['epoch'].data)/100,1)
if cull:
stride = max(len(self.val_outputs['epoch'].data)/100,1)
else:
stride = 1
for name, output in self.val_outputs.iteritems():
if name not in ['epoch']:
col_id = '%s-val' % name
Expand Down
39 changes: 39 additions & 0 deletions digits/templates/models/images/classification/large_graph.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{# Copyright (c) 2014-2015, NVIDIA CORPORATION. All rights reserved. #}

{% extends "layout.html" %}

{% block title %}
{{job.name()}} - Large graph
{% endblock %}

{% block head %}
<script src="{{ url_for('static', filename='js/model-graphs.js') }}"></script>
{% endblock %}

{% block nav %}
<li class="active"><a href="{{ url_for('show_job', job_id=job.id()) }}">{{job.job_type()}}</a></li>
{% endblock %}

{% block content %}

{% set task = job.train_task() %}

<div class="row">
<div class="col-sm-12">
<div class="well">
{% set combined_graph_data = job.train_task().combined_graph_data(cull=False) %}
{% if combined_graph_data %}
<div id="combined-graph" style="height:800px;width:100%;background:white"></div>
<script>
drawCombinedGraph({% autoescape false %}{{combined_graph_data}}{% endautoescape %});
</script>
{% else %}
<i>No data.</i>
{% endif %}

</div>
</div>
</div>

{% endblock %}

6 changes: 6 additions & 0 deletions digits/templates/models/images/classification/show.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ <h4 class='text-center'>Dataset</h4>
<div class="well">
<div id="combined-graph" class="combined-graph"
style="height:500px;width:100%;background:white;display:none;"></div>
<div class="pull-right combined-graph" style="display:none;">
<a class="btn btn-primary btn-sm" target="_blank"
href="{{url_for('image_classification_model_large_graph', job_id=job.id())}}">
View Large
</a>
</div>
<br>
<br>
{% set combined_graph_data = job.train_task().combined_graph_data() %}
Expand Down

0 comments on commit 583804b

Please sign in to comment.