Beispiel #1
0
def test_torch_nn_loss() :
    trainer = DefaultTrainer(
        optimizer=optimizer, 
        scheduler=scheduler, 
        model=model, 
        criterion=loss_fn, 
        experiment_logger=experiment_logger
    )
Beispiel #2
0
def test_construct_from_dict():
    trainer = DefaultTrainer(
        optimizer=optimizer, 
        scheduler=scheduler, 
        model=model, 
        criterion=loss_fn, 
        experiment_logger=experiment_logger
    )
Beispiel #3
0
def test_construct_from_tuple() :
    model = DummyModel()
    loss_fn = DummyLossFN()
    trainer = DefaultTrainer(
        optimizer=optimizer, 
        scheduler=scheduler, 
        model=model, 
        criterion=loss_fn, 
        experiment_logger=experiment_logger
    )
Beispiel #4
0
def test_broken_construct_from_tuple_2() :
    with pytest.warns(UserWarning) as e:
        ## default trainer only warns
        loss_fn = BrokenDummyLossFN()
        trainer = DefaultTrainer(
            optimizer=optimizer, 
            scheduler=scheduler, 
            model=model, 
            criterion=loss_fn, 
            experiment_logger=experiment_logger
        )
    
    with pytest.raises(TypeError) as e:
        ## using strict trainer raises type error
        loss_fn = BrokenDummyLossFN()
        trainer = StrictCustomTrainer(
            optimizer=optimizer, 
            scheduler=scheduler, 
            model=model, 
            criterion=loss_fn, 
            experiment_logger=experiment_logger
        )