未验证 提交 362bdf65 编写于 作者: Y Yibing Liu 提交者: GitHub

Hide core usage (#2179)

上级 b74a5918
...@@ -26,7 +26,6 @@ import multiprocessing ...@@ -26,7 +26,6 @@ import multiprocessing
import paddle import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import paddle.fluid.core as core
import paddle.fluid.framework as framework import paddle.fluid.framework as framework
from paddle.fluid.executor import Executor from paddle.fluid.executor import Executor
...@@ -388,7 +387,7 @@ def train(logger, args): ...@@ -388,7 +387,7 @@ def train(logger, args):
optimizer.minimize(obj_func) optimizer.minimize(obj_func)
# initialize parameters # initialize parameters
place = core.CUDAPlace(0) if args.use_gpu else core.CPUPlace() place = fluid.CUDAPlace(0) if args.use_gpu else fluid.CPUPlace()
exe = Executor(place) exe = Executor(place)
if args.load_dir: if args.load_dir:
logger.info('load from {}'.format(args.load_dir)) logger.info('load from {}'.format(args.load_dir))
......
...@@ -87,9 +87,9 @@ def train(conf_dict, args): ...@@ -87,9 +87,9 @@ def train(conf_dict, args):
metric = fluid.metrics.Auc(name="auc") metric = fluid.metrics.Auc(name="auc")
# Get device # Get device
if args.use_cuda: if args.use_cuda:
place = fluid.core.CUDAPlace(0) place = fluid.CUDAPlace(0)
else: else:
place = fluid.core.CPUPlace() place = fluid.CPUPlace()
simnet_process = reader.SimNetProcessor(args, vocab) simnet_process = reader.SimNetProcessor(args, vocab)
if args.task_mode == "pairwise": if args.task_mode == "pairwise":
...@@ -244,9 +244,9 @@ def test(conf_dict, args): ...@@ -244,9 +244,9 @@ def test(conf_dict, args):
model_path = args.init_checkpoint model_path = args.init_checkpoint
# Get device # Get device
if args.use_cuda: if args.use_cuda:
place = fluid.core.CUDAPlace(0) place = fluid.CUDAPlace(0)
else: else:
place = fluid.core.CPUPlace() place = fluid.CPUPlace()
# Get executor # Get executor
executor = fluid.Executor(place=place) executor = fluid.Executor(place=place)
# Load model # Load model
...@@ -302,9 +302,9 @@ def infer(args): ...@@ -302,9 +302,9 @@ def infer(args):
model_path = args.init_checkpoint model_path = args.init_checkpoint
# Get device # Get device
if args.use_cuda: if args.use_cuda:
place = fluid.core.CUDAPlace(0) place = fluid.CUDAPlace(0)
else: else:
place = fluid.core.CPUPlace() place = fluid.CPUPlace()
# Get executor # Get executor
executor = fluid.Executor(place=place) executor = fluid.Executor(place=place)
# Load model # Load model
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册