test_sgd_op.py 530 字节
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")
11
        lr = np.array([0.1]).astype("float32")
D
dangqingqing 已提交
12

13 14
        self.inputs = {'Param': w, 'Grad': g, 'LearningRate': lr}
        self.outputs = {'ParamOut': 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()