Exemplo n.º 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)
Exemplo n.º 2
0
 def test_save_forward(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_forward.pth'
     nll.save_forward(outfilename)
     self.assertTrue(os.path.exists(outfilename))
     self.addCleanup(os.remove, outfilename)
Exemplo n.º 3
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()
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
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)
Exemplo n.º 9
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)