def test_set_lrs_with_list_of_values(): lo = LayerOptimizer(FakeOpt, params_('A', 'B', 'C'), 1e-2, 1e-4) lo.set_lrs([2e-2, 3e-2, 4e-2]) check_optimizer_( lo.opt, [('A', 2e-2, 1e-4), ('B', 3e-2, 1e-4), ('C', 4e-2, 1e-4)], )
def test_set_lrs_list(self): lo = LayerOptimizer(FakeOpt, params_('A', 'B', 'C'), 1e-2, 1e-4) lo.set_lrs([2e-2, 3e-2, 4e-2]) self.check_optimizer_( lo.opt, [('A', 2e-2, 1e-4), ('B', 3e-2, 1e-4), ('C', 4e-2, 1e-4)], )
def test_set_lrs_with_list_of_values(): lo = LayerOptimizer(FakeOpt, params_('A', 'B', 'C'), 1e-2, 1e-4) lo.set_lrs([2e-2, 3e-2, 4e-2]) check_optimizer_( lo.opt, [('A', 2e-2, 1e-4), ('B', 3e-2, 1e-4), ('C', 4e-2, 1e-4)], )
def test_set_lrs_with_list_of_values(): lo = LayerOptimizer(FakeOpt, params_("A", "B", "C"), 1e-2, 1e-4) lo.set_lrs([2e-2, 3e-2, 4e-2]) check_optimizer_( lo.opt, [("A", 2e-2, 1e-4), ("B", 3e-2, 1e-4), ("C", 4e-2, 1e-4)], )
def test_set_lrs_with_too_few_values(): lo = LayerOptimizer(FakeOpt, params_('A', 'B', 'C'), 1e-2, 1e-4) with pytest.raises(AssertionError): lo.set_lrs([2e-2, 3e-2]) # Also make sure the optimizer didn't change. check_optimizer_(lo.opt, [(nm, 1e-2, 1e-4) for nm in 'ABC'])
def test_set_lrs_with_single_value(): lo = LayerOptimizer(FakeOpt, params_('A', 'B', 'C'), 1e-2, 1e-4) lo.set_lrs(1e-3) check_optimizer_(lo.opt, [(nm, 1e-3, 1e-4) for nm in 'ABC'])
def test_set_lrs_with_too_few_values(): lo = LayerOptimizer(FakeOpt, params_('A', 'B', 'C'), 1e-2, 1e-4) with pytest.raises(AssertionError): lo.set_lrs([2e-2, 3e-2]) # Also make sure the optimizer didn't change. check_optimizer_(lo.opt, [(nm, 1e-2, 1e-4) for nm in 'ABC'])
def test_set_lrs_with_single_value(): lo = LayerOptimizer(FakeOpt, params_('A', 'B', 'C'), 1e-2, 1e-4) lo.set_lrs(1e-3) check_optimizer_(lo.opt, [(nm, 1e-3, 1e-4) for nm in 'ABC'])
def test_set_lrs_malformed(self): lo = LayerOptimizer(FakeOpt, params_('A', 'B', 'C'), 1e-2, 1e-4) with self.assertRaises(AssertionError): lo.set_lrs([2e-2, 3e-2]) self.check_optimizer_(lo.opt, [(nm, 1e-2, 1e-4) for nm in 'ABC'])
def test_set_lrs_atomic(self): lo = LayerOptimizer(FakeOpt, params_('A', 'B', 'C'), 1e-2, 1e-4) lo.set_lrs(1e-3) self.check_optimizer_(lo.opt, [(nm, 1e-3, 1e-4) for nm in 'ABC'])
def test_set_lrs_with_single_value(): lo = LayerOptimizer(FakeOpt, params_("A", "B", "C"), 1e-2, 1e-4) lo.set_lrs(1e-3) check_optimizer_(lo.opt, [(nm, 1e-3, 1e-4) for nm in "ABC"])