From cc33d92362bb29698d1103bc175cb610097c4a3d Mon Sep 17 00:00:00 2001 From: sneaxiy Date: Thu, 20 Sep 2018 02:54:15 +0000 Subject: [PATCH] fix bug --- fluid/deep_attention_matching_net/train_and_evaluate.py | 2 +- fluid/deep_attention_matching_net/utils/layers.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fluid/deep_attention_matching_net/train_and_evaluate.py b/fluid/deep_attention_matching_net/train_and_evaluate.py index 9153051d..3e46d6e1 100644 --- a/fluid/deep_attention_matching_net/train_and_evaluate.py +++ b/fluid/deep_attention_matching_net/train_and_evaluate.py @@ -128,7 +128,7 @@ def train(args): dev_count = fluid.core.get_cuda_device_count() else: place = fluid.CPUPlace() - dev_count = multiprocessing.cpu_count() + dev_count = int(os.environ.get('CPU_NUM', multiprocessing.cpu_count())) print("device count %d" % dev_count) diff --git a/fluid/deep_attention_matching_net/utils/layers.py b/fluid/deep_attention_matching_net/utils/layers.py index e94308f7..530c6ba5 100644 --- a/fluid/deep_attention_matching_net/utils/layers.py +++ b/fluid/deep_attention_matching_net/utils/layers.py @@ -82,7 +82,10 @@ def dot_product_attention(query, else: mask = fluid.layers.matmul(x=q_mask, y=k_mask, transpose_y=True) another_mask = fluid.layers.scale( - mask, scale=2**32 - 1, bias=-1, bias_after_scale=False) + mask, + scale=float(2**32 - 1), + bias=float(-1), + bias_after_scale=False) if mask_cache is not None: if q_mask.name not in mask_cache: mask_cache[q_mask.name] = dict() -- GitLab