未验证 提交 2a167ec9 编写于 作者: H hutuxian 提交者: GitHub

add check version (#3530)

Add version checking for DIN and SR-GNN.
上级 e743c29c
...@@ -29,6 +29,7 @@ DIN通过一个兴趣激活模块(Activation Unit),用预估目标Candidate AD ...@@ -29,6 +29,7 @@ DIN通过一个兴趣激活模块(Activation Unit),用预估目标Candidate AD
最后我们将这相关的用户兴趣表达、用户静态特征和上下文相关特征,以及ad相关的特征拼接起来,输入到后续的多层DNN网络,最后预测得到用户对当前目标ADs的点击概率。 最后我们将这相关的用户兴趣表达、用户静态特征和上下文相关特征,以及ad相关的特征拼接起来,输入到后续的多层DNN网络,最后预测得到用户对当前目标ADs的点击概率。
**目前模型库下模型均要求使用PaddlePaddle 1.6及以上版本或适当的develop版本。**
## 数据下载及预处理 ## 数据下载及预处理
......
...@@ -9,6 +9,7 @@ import time ...@@ -9,6 +9,7 @@ import time
import network import network
import reader import reader
import random import random
import sys
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger("fluid") logger = logging.getLogger("fluid")
...@@ -85,7 +86,7 @@ def train(): ...@@ -85,7 +86,7 @@ def train():
#data_reader, max_len = reader.prepare_reader(train_path, args.batch_size) #data_reader, max_len = reader.prepare_reader(train_path, args.batch_size)
logger.info("reading data completes") logger.info("reading data completes")
avg_cost, pred = network.network(item_count, cat_count, 433) avg_cost, pred = network.network(item_count, cat_count)
#fluid.clip.set_gradient_clip(clip=fluid.clip.GradientClipByGlobalNorm(clip_norm=5.0)) #fluid.clip.set_gradient_clip(clip=fluid.clip.GradientClipByGlobalNorm(clip_norm=5.0))
base_lr = args.base_lr base_lr = args.base_lr
boundaries = [410000] boundaries = [410000]
...@@ -167,6 +168,21 @@ def train(): ...@@ -167,6 +168,21 @@ def train():
logger.info("run trainer") logger.info("run trainer")
train_loop(t.get_trainer_program()) train_loop(t.get_trainer_program())
def check_version():
"""
Log error and exit when the installed version of paddlepaddle is
not satisfied.
"""
err = "PaddlePaddle version 1.6 or higher is required, " \
"or a suitable develop version is satisfied as well. \n" \
"Please make sure the version is good with your code." \
try:
fluid.require_version('1.6.0')
except Exception as e:
logger.error(err)
sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
check_version()
train() train()
...@@ -19,6 +19,7 @@ import os ...@@ -19,6 +19,7 @@ import os
import paddle import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import reader import reader
import sys
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger("fluid") logger = logging.getLogger("fluid")
...@@ -99,6 +100,21 @@ def infer(): ...@@ -99,6 +100,21 @@ def infer():
auc = calc_auc(score) auc = calc_auc(score)
logger.info("TEST --> loss: {}, auc: {}".format(loss_sum / count, auc)) logger.info("TEST --> loss: {}, auc: {}".format(loss_sum / count, auc))
def check_version():
"""
Log error and exit when the installed version of paddlepaddle is
not satisfied.
"""
err = "PaddlePaddle version 1.6 or higher is required, " \
"or a suitable develop version is satisfied as well. \n" \
"Please make sure the version is good with your code." \
try:
fluid.require_version('1.6.0')
except Exception as e:
logger.error(err)
sys.exit(1)
if __name__ == '__main__': if __name__ == '__main__':
check_version()
infer() infer()
...@@ -173,6 +173,21 @@ def get_cards(args): ...@@ -173,6 +173,21 @@ def get_cards(args):
else: else:
return args.num_devices return args.num_devices
def check_version():
"""
Log error and exit when the installed version of paddlepaddle is
not satisfied.
"""
err = "PaddlePaddle version 1.6 or higher is required, " \
"or a suitable develop version is satisfied as well. \n" \
"Please make sure the version is good with your code." \
try:
fluid.require_version('1.6.0')
except Exception as e:
logger.error(err)
sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
check_version()
train() train()
...@@ -31,6 +31,7 @@ SR-GNN模型的介绍可以参阅论文[Session-based Recommendation with Graph ...@@ -31,6 +31,7 @@ SR-GNN模型的介绍可以参阅论文[Session-based Recommendation with Graph
我们复现了论文效果,在DIGINETICA数据集上P@20可以达到50.7 我们复现了论文效果,在DIGINETICA数据集上P@20可以达到50.7
**目前模型库下模型均要求使用PaddlePaddle 1.6及以上版本或适当的develop版本。**
## 数据下载及预处理 ## 数据下载及预处理
......
...@@ -20,6 +20,7 @@ import paddle ...@@ -20,6 +20,7 @@ import paddle
import paddle.fluid as fluid import paddle.fluid as fluid
import reader import reader
import network import network
import sys
logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s') logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s')
logger = logging.getLogger("fluid") logger = logging.getLogger("fluid")
...@@ -87,6 +88,22 @@ def infer(args): ...@@ -87,6 +88,22 @@ def infer(args):
logger.info("TEST --> error: there is no model in " + model_path) logger.info("TEST --> error: there is no model in " + model_path)
def check_version():
"""
Log error and exit when the installed version of paddlepaddle is
not satisfied.
"""
err = "PaddlePaddle version 1.6 or higher is required, " \
"or a suitable develop version is satisfied as well. \n" \
"Please make sure the version is good with your code." \
try:
fluid.require_version('1.6.0')
except Exception as e:
logger.error(err)
sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
check_version()
args = parse_args() args = parse_args()
infer(args) infer(args)
...@@ -170,6 +170,21 @@ def get_cards(args): ...@@ -170,6 +170,21 @@ def get_cards(args):
num = len(cards.split(",")) num = len(cards.split(","))
return num return num
def check_version():
"""
Log error and exit when the installed version of paddlepaddle is
not satisfied.
"""
err = "PaddlePaddle version 1.6 or higher is required, " \
"or a suitable develop version is satisfied as well. \n" \
"Please make sure the version is good with your code." \
try:
fluid.require_version('1.6.0')
except Exception as e:
logger.error(err)
sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
check_version()
train() train()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册