ValueError:在Conv2D节点中,输入和筛选器形状必须为int或symbol

2024-04-20 01:12:57 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试图使用tfcoreml(使用下面的脚本)将我的.pb文件转换为CoreML模型,但出现了以下错误:ValueError: Input and filter shapes must be int or symbolic in Conv2D node detector/darknet-53/Conv/Conv2D。如何解决此错误并将模型成功转换为CoreML

我用Netron打开了我的.pb模型,发现了有问题的图层:

Netron Graph

以下是我正在使用的转换脚本:

import tfcoreml

tfcoreml.convert(tf_model_path='model.pb',
                 mlmodel_path='model.mlmodel',
                 output_feature_names=['output_boxes'],  # name of the output op
                 input_name_shape_dict={'inputs': [None, 416, 416, 3]},  # map from the placeholder op in the graph to shape (can have -1s)
                 minimum_ios_deployment_target='13')

从我所能收集到的信息来看,我似乎需要更改所有Conv2D节点的输入类型以使其正常工作。但我无论如何都不是专家,所以我可能是错的。有没有一种方法可以通过使用Python脚本修复此模型以成功转换,如果有,它会是什么样子

编辑:在更改input_name_shape_dict中的None之后,我得到了一个不同的错误。这个上面写着:ValueError: Incompatible dimension 3 in Sub operation detector/darknet-53/Conv/BatchNorm/FusedBatchNorm/Sub。于是我再次打开Netron,我看了一眼。这是我得到的,知道怎么修吗

Netron Graph 2

脚本似乎越过了上一个错误,只是为了进入下一层。我的.pb是完全无用还是只需要在某些地方进行修复


Tags: thenamein模型脚本outputmodel错误