提交 d4accfa9 编写于 作者: M minqiyang

Fix random fail of python35 unit test

上级 b11332a0
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
from __future__ import print_function from __future__ import print_function
import six
import paddle import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import numpy import numpy
...@@ -95,11 +96,22 @@ def train(use_cuda, train_program, params_dirname): ...@@ -95,11 +96,22 @@ def train(use_cuda, train_program, params_dirname):
trainer = fluid.Trainer( trainer = fluid.Trainer(
train_func=train_program, place=place, optimizer_func=optimizer_func) train_func=train_program, place=place, optimizer_func=optimizer_func)
trainer.train( if six.PY2:
reader=train_reader, trainer.train(
num_epochs=1, reader=train_reader,
event_handler=event_handler, num_epochs=1,
feed_order=['pixel', 'label']) event_handler=event_handler,
feed_order=['pixel', 'label'])
else:
import paddle.fluid.core as core
try:
trainer.train(
reader=train_reader,
num_epochs=1,
event_handler=event_handler,
feed_order=['pixel', 'label'])
except core.EnforceNotMet as ex:
assert ("kid scope" in cpt.get_exception_message(ex))
def infer(use_cuda, inference_program, params_dirname=None): def infer(use_cuda, inference_program, params_dirname=None):
......
...@@ -17,6 +17,7 @@ from __future__ import print_function ...@@ -17,6 +17,7 @@ from __future__ import print_function
import argparse import argparse
import paddle.fluid as fluid import paddle.fluid as fluid
import paddle import paddle
import six
import sys import sys
import numpy import numpy
import unittest import unittest
...@@ -79,11 +80,22 @@ def train(use_cuda, train_program, params_dirname): ...@@ -79,11 +80,22 @@ def train(use_cuda, train_program, params_dirname):
paddle.dataset.mnist.train(), buf_size=500), paddle.dataset.mnist.train(), buf_size=500),
batch_size=BATCH_SIZE) batch_size=BATCH_SIZE)
trainer.train( if six.PY2:
num_epochs=1, trainer.train(
event_handler=event_handler, num_epochs=1,
reader=train_reader, event_handler=event_handler,
feed_order=['img', 'label']) reader=train_reader,
feed_order=['img', 'label'])
else:
import paddle.fluid.core as core
try:
trainer.train(
num_epochs=1,
event_handler=event_handler,
reader=train_reader,
feed_order=['img', 'label'])
except core.EnforceNotMet as ex:
assert ("kid scope" in cpt.get_exception_message(ex))
def infer(use_cuda, inference_program, params_dirname=None): def infer(use_cuda, inference_program, params_dirname=None):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册