- 背景:
预测的时候加入了一些特有的业务逻辑过滤,需要对每一层结果进行处理,因此把整个组网拆开来了,每个组网在一个program下
- 版本、环境信息:
1)PaddlePaddle版本:1.7.2
2)CPU:本地cpu预测
3)系统环境:Python版本2.7
- 问题描述:请详细描述您的问题,同步贴出报错信息、日志/代码关键片段
InvalidArgumentError: The input tensor X's dimensions of MulOp should be larger than x_num_col_dims. But received X's dimensions = 1, X's shape = [0], x_num_col_dims = 1.
[Hint: Expected x_dims.size() > x_num_col_dims, but received x_dims.size():1 <= x_num_col_dims:1.] at (/paddle/paddle/fluid/operators/mul_op.cc:68)
[operator < mul > error]
Python Call Stacks (More useful to users):
File "/home/disk3/wangfang20/baidu/adx/sublink-tdm/sublink_tdm/python/lib/python2.7/site-packages/paddle/fluid/framework.py", line 2525, in append_op
attrs=kwargs.get("attrs", None))
File "/home/disk3/wangfang20/baidu/adx/sublink-tdm/sublink_tdm/python/lib/python2.7/site-packages/paddle/fluid/layer_helper.py", line 43, in append_op
return self.main_program.current_block().append_op(*args,**kwargs)
File "/home/disk3/wangfang20/baidu/adx/sublink-tdm/sublink_tdm/python/lib/python2.7/site-packages/paddle/fluid/layers/nn.py", line 342, in fc
"y_num_col_dims": 1})
File "/home/disk3/wangfang20/baidu/adx/sublink-tdm/sublink_tdm/network.py", line 241, in input_fc_infer
bias_attr=fluid.ParamAttr(name="trans.input_fc.bias")
File "local_infer.py", line 156, in run_infer
input_fc_out = input_net.input_fc_infer(input)
File "local_infer.py", line 273, in
run_infer(args, path)
local_infer.py
def run_infer(args, model_path):
"""run infer"""
logger.info("Infer Begin")
file_list = [
str(args.test_files_path) + "/%s" % x
for x in os.listdir(args.test_files_path)
]
test_reader = TDMDataset().infer_reader(file_list, args.batch_size)
node2item = get_node2item(args)
#### 这里调用network#####
input_net = InputTransNet(args)
input = input_net.input_data()
place = fluid.CPUPlace()
exe = fluid.Executor(place)
path = os.path.join(args.model_files_path, model_path)
# 各类组网program
startup_program = fluid.Program()
# input_embedding
input_main_program = fluid.Program()
#### 报错地方#####
with fluid.program_guard(input_main_program, startup_program):
input_fc_out = input_net.input_fc_infer(input)
fluid.io.load_persistables(
executor=exe,
dirname=path,
main_program=input_main_program)
logger.info("Load persistables for input_embedding program from \"{}\"".format(path))
network.py
class InputTransNet(object):
"""
doc
"""
def __init__(self, args):
self.input_embed_size = args.query_emb_size
self.node_embed_size = args.node_emb_size
self.max_layers = args.layer_size
self.is_test = args.is_test
def input_data(self):
"""
doc
"""
input_emb = fluid.layers.data(
name="input_emb",
shape=[self.input_embed_size],
dtype="float32",
)
return input_emb
def input_trans_layer(self, input_emb):
"""
doc
"""
input_fc_out = fluid.layers.fc(
input=input_emb,
size=self.node_embed_size,
act=None,
param_attr=fluid.ParamAttr(name="trans.input_fc.weight"),
bias_attr=fluid.ParamAttr(name="trans.input_fc.bias"),
)
input_layer_fc_out = [
fluid.layers.fc(
input=input_fc_out,
size=self.node_embed_size,
act="tanh",
param_attr=fluid.ParamAttr(
name="trans.layer_fc.weight." + str(i)),
bias_attr=fluid.ParamAttr(name="trans.layer_fc.bias." + str(i)),
) for i in range(self.max_layers)
]
return input_layer_fc_out
def input_fc_infer(self, input_emb):
"""
doc
"""
input_fc_out = fluid.layers.fc(
input=input_emb,
size=self.node_embed_size,
act=None,
param_attr=fluid.ParamAttr(name="trans.input_fc.weight"),
bias_attr=fluid.ParamAttr(name="trans.input_fc.bias")
)
return input_fc_out
def layer_fc_infer(self, input_fc_out, layer_idx):
"""
doc
"""
input_layer_fc_out = fluid.layers.fc(
input=input_fc_out,
size=self.node_embed_size,
act="tanh",
param_attr=fluid.ParamAttr(name="trans.layer_fc.weight." + str(layer_idx)),
bias_attr=fluid.ParamAttr(name="trans.layer_fc.bias." + str(layer_idx))
)
return input_layer_fc_out
暂无答案!
目前还没有任何答案,快来回答吧!