keras-onnx icon indicating copy to clipboard operation
keras-onnx copied to clipboard

AttributeError: 'list' object has no attribute 'name'

Open juliansjungwirth opened this issue 4 years ago • 1 comments

Converting a tf-keras 2.2.0/2.3.0 model with multiple output tensors to onnx, I faced the following error:

... in extract_outputs_from_inbound_nodes
    op_name = tsname_to_node(ts_.name)
AttributeError: 'list' object has no attribute 'name'

A potential solution that worked for me is:

# enable the following lines from _parser_tf.py to be compatible with list-outputs:
for ts_ in output_tensors:
    op_name = tsname_to_node(ts_.name)
    if op_name not in output_dict:
        output_dict[op_name] = (model, None)         

--->

 for ts_ in output_tensors:
    if not isinstance(ts_, (tuple, list)):
        ts_ = [ts_]
    for ts__ in ts_:
        op_name = tsname_to_node(ts__.name)
        if op_name not in output_dict:
            output_dict[op_name] = (model, None)

Maybe, in a future version, it is possible to pay respect to these kinds of outputs. Thanks and kind regards :)

juliansjungwirth avatar Aug 28 '20 09:08 juliansjungwirth

@julianjungwirth , would you please propose your fixing as a PR to help other as well?

wenbingl avatar Oct 22 '20 18:10 wenbingl