Closed Bella-Zhao closed 1 year ago
建议使用fill_const_batch_size_like,https://www.paddlepaddle.org.cn/documentation/docs/zh/1.5/api_cn/layers_cn/tensor_cn.html#fill-constant-batch-size-like context_user_emb = fluid.layers.fill_constant_batch_size_like(input=like, shape=[embedding_size], dtype='float32', value=0.0)
最后改成这样定义了,不报错了。
context_user_emb = None
context_doc_emb = None
user_context_emb = None
user_doc_emb = None
doc_context_emb = None
doc_user_emb = None
# context
for feature_name in global_def.CONTEXT_FEATURE_LIST:
if context_user_emb is None:
context_user_emb = dict_emb[feature_name]['user']
else:
context_user_emb += dict_emb[feature_name]['user']
if context_doc_emb is None:
context_doc_emb = dict_emb[feature_name]['doc']
else:
context_doc_emb += dict_emb[feature_name]['doc']
报错信息:
code:
code说明:模型实现了FFM,想要对不同域的embedding做sum pooling操作。在循环中用context_user_emb += ...的操作,所以需要在循环外先定义变量context_user_emb,可能报错是从这里出来的: