提交 792719fb 编写于 作者: X Xin Pan

polish test

test=develop
上级 54f4d585
...@@ -12,13 +12,9 @@ ...@@ -12,13 +12,9 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
import contextlib
import unittest import unittest
import numpy as np import numpy as np
import six
import sys
import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
from paddle.fluid.layer_helper import LayerHelper from paddle.fluid.layer_helper import LayerHelper
...@@ -74,18 +70,12 @@ class TestBaseLayer(unittest.TestCase): ...@@ -74,18 +70,12 @@ class TestBaseLayer(unittest.TestCase):
self.assertEqual(l.w1.name, "MyLayer_0.w_0") self.assertEqual(l.w1.name, "MyLayer_0.w_0")
self.assertEqual(l.w2.name, "MyLayer_0.w_1") self.assertEqual(l.w2.name, "MyLayer_0.w_1")
self.assertTrue(np.allclose(ret._numpy(), 0.2 * np.ones([2, 2]))) self.assertTrue(np.allclose(ret._numpy(), 0.2 * np.ones([2, 2])))
sys.stderr.write(
'%s %s %s %s\n' %
(ret._numpy(), l.w1.name, l.w2.name, l._sub_layers))
def test_three_level(self): def test_three_level(self):
with fluid.imperative.guard(): with fluid.imperative.guard():
l = L3() l = L3()
ret = l() ret = l()
sys.stderr.write('%s\n' % ret._numpy()) self.assertTrue(np.allclose(ret._numpy(), 0.8 * np.ones([2, 2])))
for p in l.parameters():
sys.stderr.write('%s\n' % p.name)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册