You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_optimizer.py 452 B

123456789101112131415161718192021
  1. import unittest
  2. import torch
  3. from fastNLP.core.optimizer import SGD
  4. class TestOptim(unittest.TestCase):
  5. def test_case(self):
  6. optim = SGD(torch.LongTensor(10))
  7. print(optim.__dict__)
  8. optim_2 = SGD(lr=0.001)
  9. print(optim_2.__dict__)
  10. optim_2 = SGD(lr=0.002, momentum=0.989)
  11. print(optim_2.__dict__)
  12. def test_case_2(self):
  13. with self.assertRaises(RuntimeError):
  14. _ = SGD(0.001)