Beispiel #1
0
 def test_train_05(self):
     nll = NonlinearLevelSet(n_layers=2, active_dim=1, lr=0.02, epochs=1)
     with assert_plot_figures_added():
         nll.train(inputs=inputs_torch,
                   gradients=grad_torch,
                   outputs=lift,
                   interactive=True)
Beispiel #2
0
 def test_save_backward(self):
     nll = NonlinearLevelSet(n_layers=2, active_dim=1, lr=0.02, epochs=1)
     nll.train(inputs=inputs_torch, gradients=grad_torch, interactive=False)
     outfilename = 'tests/data/saved_backward.pth'
     nll.save_backward(outfilename)
     nll.save_backward('tests/data/backward_test.pth')
     self.assertTrue(os.path.exists(outfilename))
     self.addCleanup(os.remove, outfilename)
Beispiel #3
0
 def test_init_loss_vec(self):
     nll = NonlinearLevelSet(n_layers=2,
                             active_dim=1,
                             lr=0.1,
                             epochs=100,
                             dh=0.25)
     self.assertEqual(nll.loss_vec, [])
Beispiel #4
0
 def test_init_backward(self):
     nll = NonlinearLevelSet(n_layers=2,
                             active_dim=1,
                             lr=0.1,
                             epochs=100,
                             dh=0.25)
     self.assertIsNone(nll.backward)
Beispiel #5
0
 def test_load_backward(self):
     nll = NonlinearLevelSet(n_layers=2, active_dim=1, lr=0.02, epochs=1)
     nll.load_backward(infile='tests/data/backward_test.pth', n_params=18)
     self.assertIsInstance(nll.backward, BackwardNet)
Beispiel #6
0
 def test_plot_loss(self):
     nll = NonlinearLevelSet(n_layers=2, active_dim=1, lr=0.02, epochs=2)
     nll.train(inputs=inputs_torch, gradients=grad_torch, interactive=False)
     with assert_plot_figures_added():
         nll.plot_loss()
Beispiel #7
0
 def test_plot_sufficient_summary_02(self):
     nll = NonlinearLevelSet(n_layers=2, active_dim=2, lr=0.02, epochs=1)
     nll.train(inputs=inputs_torch, gradients=grad_torch, interactive=False)
     with self.assertRaises(ValueError):
         nll.plot_sufficient_summary(inputs=inputs_torch, outputs=lift)
Beispiel #8
0
 def test_plot_sufficient_summary_01(self):
     nll = NonlinearLevelSet(n_layers=2, active_dim=1, lr=0.02, epochs=1)
     nll.train(inputs=inputs_torch, gradients=grad_torch, interactive=False)
     with assert_plot_figures_added():
         nll.plot_sufficient_summary(inputs=inputs_torch, outputs=lift)
Beispiel #9
0
 def test_backward_n_params(self):
     nll = NonlinearLevelSet(n_layers=2, active_dim=1, lr=0.02, epochs=1)
     nll.train(inputs=inputs_torch, gradients=grad_torch, interactive=False)
     self.assertEqual(nll.backward.n_params, 9)
Beispiel #10
0
 def test_train_04(self):
     nll = NonlinearLevelSet(n_layers=2, active_dim=1, lr=0.02, epochs=1)
     with self.assertRaises(ValueError):
         nll.train(inputs=inputs_torch,
                   gradients=grad_torch,
                   interactive=True)
Beispiel #11
0
 def test_train_03(self):
     nll = NonlinearLevelSet(n_layers=2, active_dim=1, lr=0.02, epochs=1)
     nll.train(inputs=inputs_torch, gradients=grad_torch, interactive=False)
     self.assertIs(len(nll.loss_vec), 1)
Beispiel #12
0
 def test_train_02(self):
     nll = NonlinearLevelSet(n_layers=2, active_dim=1, lr=0.02, epochs=1)
     nll.train(inputs=inputs_torch, gradients=grad_torch, interactive=False)
     self.assertIsInstance(nll.backward, BackwardNet)