test_sgd_op.py 502 字节
Newer Older
Q
Qiao Longfei 已提交
1
import unittest
Q
qijun 已提交
2 3
import numpy as np
from op_test import OpTest
Q
Qiao Longfei 已提交
4 5


6
class TestSGDOp(OpTest):
Q
Qiao Longfei 已提交
7
    def setUp(self):
Q
qijun 已提交
8 9 10
        self.op_type = "sgd"
        w = np.random.random((102, 105)).astype("float32")
        g = np.random.random((102, 105)).astype("float32")
D
dangqingqing 已提交
11 12
        lr = 0.1

13
        self.inputs = {'param': w, 'grad': g, 'learning_rate': lr}
D
dangqingqing 已提交
14
        self.outputs = {'param_out': w - lr * g}
Q
Qiao Longfei 已提交
15

Q
qijun 已提交
16 17 18
    def test_check_output(self):
        self.check_output()

Q
Qiao Longfei 已提交
19 20 21

if __name__ == "__main__":
    unittest.main()