Integrate ebarsoum/BSvsPython into master

This commit is contained in:
Project Philly 2016-11-02 23:33:11 -07:00
Родитель b308ad9363 de511fca9f
Коммит 1eeb899d9a
5 изменённых файлов: 12 добавлений и 6 удалений

Просмотреть файл

@ -22,6 +22,9 @@
%rename(momentum_as_time_constant_schedule) CNTK::MomentumAsTimeConstantSchedule; %rename(momentum_as_time_constant_schedule) CNTK::MomentumAsTimeConstantSchedule;
%rename(l1_regularization_weight) CNTK::AdditionalLearningOptions::l1RegularizationWeight;
%rename(l2_regularization_weight) CNTK::AdditionalLearningOptions::l2RegularizationWeight;
// if we don't except RandomUniform the corresponding template functions will not be generated // if we don't except RandomUniform the corresponding template functions will not be generated
%rename("%(utitle)s", %$isfunction, notregexmatch$name="RandomUniform") ""; %rename("%(utitle)s", %$isfunction, notregexmatch$name="RandomUniform") "";
%rename("%(utitle)s", %$isvariable) ""; %rename("%(utitle)s", %$isvariable) "";

Просмотреть файл

@ -42,7 +42,7 @@ def run_distributed_trainer(tmpdir, quantized):
momentum_time_constant = momentum_as_time_constant_schedule(1100) momentum_time_constant = momentum_as_time_constant_schedule(1100)
trainer = Trainer(z, ce, errs, \ trainer = Trainer(z, ce, errs, \
sgd(z.parameters, 0.007, momentum_time_constant, 0.5, True), momentum_sgd(z.parameters, 0.007, momentum_time_constant),
distributed_trainer=dist_trainer) distributed_trainer=dist_trainer)
in1_value = [[1],[2]] in1_value = [[1],[2]]
label_value = [[0], [1]] label_value = [[0], [1]]

Просмотреть файл

@ -23,7 +23,7 @@ def test_trainer(tmpdir):
m_schedule = momentum_schedule(1100) m_schedule = momentum_schedule(1100)
trainer = Trainer(z, ce, errs, \ trainer = Trainer(z, ce, errs, \
[sgd(z.parameters, 0.007, m_schedule, 0.5, True)]) [momentum_sgd(z.parameters, 0.007, m_schedule)])
in1_value = [[1],[2]] in1_value = [[1],[2]]
label_value = [[0], [1]] label_value = [[0], [1]]
arguments = {in1: in1_value, labels: label_value} arguments = {in1: in1_value, labels: label_value}
@ -52,7 +52,7 @@ def test_output_to_retain():
m_schedule = momentum_schedule(1100) m_schedule = momentum_schedule(1100)
trainer = Trainer(z, ce, errs, \ trainer = Trainer(z, ce, errs, \
[sgd(z.parameters, 0.007, m_schedule, 0.5, True)]) [momentum_sgd(z.parameters, 0.007, m_schedule)])
in1_value = [[1],[2]] in1_value = [[1],[2]]
label_value = [[0], [1]] label_value = [[0], [1]]
arguments = {in1: in1_value, labels: label_value} arguments = {in1: in1_value, labels: label_value}

Просмотреть файл

@ -1,4 +1,4 @@
# Copyright (c) Microsoft. All rights reserved. # Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE.md file in the project root # Licensed under the MIT license. See LICENSE.md file in the project root
# for full license information. # for full license information.
@ -157,7 +157,10 @@ def sequence_to_sequence_translator(debug_output=False, run_test=False):
momentum_time_constant = momentum_as_time_constant_schedule(1100) momentum_time_constant = momentum_as_time_constant_schedule(1100)
clipping_threshold_per_sample = 2.3 clipping_threshold_per_sample = 2.3
gradient_clipping_with_truncation = True gradient_clipping_with_truncation = True
learner = momentum_sgd(z.parameters, lr_per_sample, momentum_time_constant, clipping_threshold_per_sample, gradient_clipping_with_truncation) learner = momentum_sgd(z.parameters,
lr_per_sample, momentum_time_constant,
gradient_clipping_threshold_per_sample=clipping_threshold_per_sample,
gradient_clipping_with_truncation=gradient_clipping_with_truncation)
trainer = Trainer(z, ce, errs, learner) trainer = Trainer(z, ce, errs, learner)
# setup data # setup data

Просмотреть файл

@ -44,7 +44,7 @@ def test_cifar_resnet_error(device_id):
reader_test = create_reader(os.path.join(base_path, 'test_map.txt'), os.path.join(base_path, 'CIFAR-10_mean.xml'), False) reader_test = create_reader(os.path.join(base_path, 'test_map.txt'), os.path.join(base_path, 'CIFAR-10_mean.xml'), False)
test_error = train_and_evaluate(reader_train, reader_test, max_epochs=5) test_error = train_and_evaluate(reader_train, reader_test, max_epochs=5)
expected_test_error = 0.384 expected_test_error = 0.36
assert np.allclose(test_error, expected_test_error, assert np.allclose(test_error, expected_test_error,
atol=TOLERANCE_ABSOLUTE) atol=TOLERANCE_ABSOLUTE)