def test_classification_3(): runner = tasks.ClassificationRunner(model, optimizer, nn.CrossEntropyLoss(), TensorBoardLogger()) try: runner.fit(x.astype(np.float32), y.astype(np.int64)) is_pass = True except Exception: is_pass = False assert is_pass is True
def test_regression_2(): runner = tasks.RegressionRunner(model, optimizer, nn.MSELoss(), TensorBoardLogger("./logs")) runner.train_config(epochs=1) try: runner.run(verbose=False) is_pass = True except Exception: is_pass = False assert is_pass is False
def test_classification_2(): runner = tasks.ClassificationRunner(model, optimizer, nn.CrossEntropyLoss(), TensorBoardLogger()) runner.train_config(epochs=1) try: runner.run(verbose=False) is_pass = True except Exception: is_pass = False assert is_pass is False
def test_regression_3(): runner = tasks.RegressionRunner(model, optimizer, nn.MSELoss(), TensorBoardLogger("./logs")) try: runner.fit(x.astype(np.float32), y.astype(np.float32), batch_size=32, epochs=1) is_pass = True except Exception: is_pass = False assert is_pass is True
def test_classification_1(): runner = tasks.ClassificationRunner(model, optimizer, nn.CrossEntropyLoss(), TensorBoardLogger("./logs")) runner.add_loader("train", train_loader).add_loader("val", val_loader).add_loader( "test", test_loader) runner.train_config(epochs=1) try: runner.run(verbose=True) is_pass = True except Exception: is_pass = False assert is_pass is True
def test_classification_1(): runner = tasks.ClassificationRunner( model, optimizer, nn.CrossEntropyLoss(), TensorBoardLogger(), scheduler=[optim.lr_scheduler.ExponentialLR(optimizer, gamma=0.9)]) runner.add_loader("train", train_loader).add_loader("val", val_loader).add_loader( "test", test_loader) runner.train_config(epochs=1) try: runner.run(verbose=True) is_pass = True except Exception as e: is_pass = False print(e) assert is_pass is True
def test_regression_1(): runner = tasks.RegressionRunner( model, optimizer, nn.MSELoss(), TensorBoardLogger("./logs"), ) runner.add_loader("train", train_loader).add_loader("val", val_loader).add_loader( "test", test_loader) runner.train_config(epochs=1) try: runner.run(verbose=True) is_pass = True except Exception as e: print(e) is_pass = False assert is_pass is True
def __init__(self): super(Runner2, self).__init__() self.model = nn.Linear(10, 10) self.optimizer = optim.Adam(self.model.parameters()) self.experiment = TensorBoardLogger("../tmp") self.criterion = nn.CrossEntropyLoss()