pytorch/caffe2/python/optimizer_test.py
Luke Yeager 014d1fe5c4 Allow test discovery in caffe2/python/
Summary:
These are all essentially no-op changes which allow for nose-style (or pytest-style) test discovery.

With this patch, you can use any of these methods to discover and run tests under `caffe2/python`:
```
python -m unittest discover -p '*test*.py' caffe2/python/
python -m nose caffe2/python/
python -m pytest caffe2/python/
```

Future work:

* Get all of the tests to pass
  * Some seem to be testing operations which don't have GPU implementations
  * I get a segfault unless I set `CUDA_VISIBLE_DEVICES=0`
  * Some tests are flaky
* Allow test discovery throughout the whole project (e.g. the `experiments/` dir)
Closes https://github.com/caffe2/caffe2/pull/199

Reviewed By: pietern

Differential Revision: D4704504

Pulled By: Yangqing

fbshipit-source-id: 8f5687ec9c8aa873dfaff30dbf44272bc38a206b
2017-03-14 18:16:41 -07:00

28 lines
896 B
Python

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from caffe2.python.optimizer import build_sgd, build_ftrl, build_adagrad, build_adam
from caffe2.python.optimizer_test_util import OptimizerTestBase
from caffe2.python.test_util import TestCase
class TestSgd(OptimizerTestBase, TestCase):
def build_optimizer(self, model):
build_sgd(model, base_learning_rate=0.1)
class TestFtrl(OptimizerTestBase, TestCase):
def build_optimizer(self, model):
build_ftrl(
model, engine=None, alpha=1.0, beta=0.1, lambda1=0.0, lambda2=0.0)
class TestAdagrad(OptimizerTestBase, TestCase):
def build_optimizer(self, model):
build_adagrad(model, base_learning_rate=1.0)
class TestAdam(OptimizerTestBase, TestCase):
def build_optimizer(self, model):
build_adam(model, base_learning_rate=0.1)