Skip to content

Commit

Permalink
Cleanup iter_size commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeyeager committed May 16, 2016
1 parent 9b6e1a9 commit 26877ae
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
5 changes: 5 additions & 0 deletions digits/frameworks/caffe_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,8 @@ def get_network_visualization(self, desc):
net.name = 'Network'
return '<image src="data:image/png;base64,' + caffe.draw.draw_net(net, 'UD').encode('base64') + '" style="max-width:100%" />'

@override
def can_accumulate_gradients(self):
return (config_value('caffe_root')['version']
> parse_version('0.14.0-alpha'))

5 changes: 2 additions & 3 deletions digits/frameworks/framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def get_network_visualization(self, desc):
"""
raise NotImplementedError('Please implement me')




def can_accumulate_gradients(self):
return False

3 changes: 2 additions & 1 deletion digits/model/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ def validate_py_ext(form, field):
)

iter_size = utils.forms.IntegerField('Iteration size',
default=1,
validators = [
validators.NumberRange(min=1),
validators.Optional(),
],
tooltip = "Accumulate gradients over `iter_size` x `batch_size` instances."
tooltip = "Accumulate gradients over multiple batches (useful when you need a bigger batch size for training but it doesn't fit in memory)."
)

### Solver types
Expand Down
2 changes: 1 addition & 1 deletion digits/model/tasks/caffe_train.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def save_files_classification(self):
solver.snapshot_prefix = self.snapshot_prefix

# Iteration size
solver.iter_size = self.iter_size or 1
solver.iter_size = self.iter_size

# Epochs -> Iterations
train_iter = int(math.ceil(float(self.dataset.get_entry_count(constants.TRAIN_DB)) / train_data_layer.data_param.batch_size))
Expand Down
16 changes: 14 additions & 2 deletions digits/templates/models/images/classification/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ <h4>Solver Options</h4>
</small>
{{form.batch_size(class='form-control', placeholder='[network defaults]')}}
</div>
<div class="form-group{{mark_errors([form.iter_size])}}">
<div class="form-group{{mark_errors([form.iter_size])}}"
id="iter-size-option" style="display:none;">
{{form.iter_size.label}}
{{form.iter_size.tooltip}}
{{form.iter_size(class='form-control', placeholder='[default = 1]')}}
{{form.iter_size(class='form-control')}}
</div>
<div class="form-group{{mark_errors([form.solver_type])}}">
{{form.solver_type.label}}
Expand Down Expand Up @@ -437,6 +438,17 @@ <h4>Solver Options</h4>
$("#torch-warning").hide();
$('#stdnetRole a[href="'+"#"+fwid+"_standard"+'"]').tab('show');
$('#customFramework a[href="'+"#"+fwid+"_custom"+'"]').tab('show');

$('#iter-size-option').hide();
$('#iter_size').prop('disabled', true);
{% for fw in frameworks %}
{% if fw.can_accumulate_gradients() %}
if (fwid == "{{ fw.get_id() }}") {
$('#iter_size').prop('disabled', false);
$('#iter-size-option').show();
}
{% endif %}
{% endfor %}
}
</script>

Expand Down
2 changes: 1 addition & 1 deletion digits/templates/models/images/generic/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ <h4>Solver Options</h4>
<div class="form-group{{mark_errors([form.iter_size])}}">
{{form.iter_size.label}}
{{form.iter_size.tooltip}}
{{form.iter_size(class='form-control', placeholder='[default = 1]')}}
{{form.iter_size(class='form-control')}}
</div>
<div class="form-group{{mark_errors([form.solver_type])}}">
{{form.solver_type.label}}
Expand Down

0 comments on commit 26877ae

Please sign in to comment.