提交 d4accfa9 编写于 作者: M minqiyang

Fix random fail of python35 unit test

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