“c41365059e5547f11969dde735cd9a055218d407”上不存在“tensorflow2fluid/tf2fluid/tensorflow_graph.py”
test_scatter_op.py 715 字节
Newer Older
Z
zchen0211 已提交
1
import unittest
Q
qijun 已提交
2 3
import numpy as np
from op_test import OpTest
Z
zchen0211 已提交
4 5


Q
qijun 已提交
6
class TestScatterOp(OpTest):
Z
zchen0211 已提交
7
    def setUp(self):
Q
qijun 已提交
8 9 10 11 12
        self.op_type = "scatter"
        ref_np = np.ones((3, 3)).astype("float32")
        index_np = np.array([1, 2]).astype("int32")
        updates_np = np.random.random((2, 3)).astype("float32")
        output_np = np.copy(ref_np)
Z
zchen0211 已提交
13
        output_np[index_np] = updates_np
Z
zchen0211 已提交
14 15 16
        self.inputs = {'Ref': ref_np, 'Index': index_np, 'Updates': updates_np}
        self.outputs = {'Out': output_np}

Q
qijun 已提交
17 18
    def test_check_output(self):
        self.check_output()
Z
zchen0211 已提交
19

Q
qijun 已提交
20
    def test_check_grad(self):
Z
zchen0211 已提交
21
        self.check_grad(['Updates'], 'Out', in_place=True)
Z
zchen0211 已提交
22 23 24 25


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