在onnx转dlc的过程中出现报错:
KeyError: 'starts' 2020-09-03 15:06:11,435 - 166 - ERROR - Node Slice_4: 'starts'
or
KeyError: 'ends' 2020-09-03 15:06:11,435 - 166 - ERROR - Node Slice_4: 'ends'
定位到错误位置:
ret[name] = KNOWN_ATTRIBUTE_DEFAULTS[name]
检索KNOWN_ATTRIBUTE_DEFAULTS,发现这个字典里面没有ends和starts:
KNOWN_ATTRIBUTE_DEFAULTS = dict(dilations=[1, 1],
strides=[1, 1],
pads=[0, 0, 0, 0],
output_shape=[],
axes=[],
consumed_inputs=[],
kernel_shape=[])
修改添加starts和ends:
KNOWN_ATTRIBUTE_DEFAULTS = dict(dilations=[1, 1],
strides=[1, 1],
pads=[0, 0, 0, 0],
output_shape=[],
starts=[],
ends=[],
axes=[],
consumed_inputs=[],
kernel_shape=[])
查看整体的try except的结构:
try:
ret[name] = KNOWN_ATTRIBUTE_DEFAULTS[name]
except KeyError:
raise ValueError(code_to_message.get_error_message("ERROR_ATTRIBUTE_MISSING")(onnx_op.name, name))
修改添加成:
try:
#print('ret',ret)
#print('KNOWN_ATTRIBUTE_DEFAULTS',KNOWN_ATTRIBUTE_DEFAULTS)
#print('name',name)
if name not in KNOWN_ATTRIBUTE_DEFAULTS.keys():
print('****************************')
print(name)
pass
else:
# print("...........................")
# print(name)
ret[name] = KNOWN_ATTRIBUTE_DEFAULTS[name]
continue
# ret[name] = KNOWN_ATTRIBUTE_DEFAULTS[name]
except KeyError:
raise ValueError(code_to_message.get_error_message("ERROR_ATTRIBUTE_MISSING")(onnx_op.name, name))