解决报错“The layer xxx has never been called and thus has no defined input shape”
解决报错“The layer xxx has never been called and thus has no defined input shape”(这里写自定义目录标题)
报错显示
最近在跑yolo的代码时遇到这样一个错误,显示“the layer {self.name} has never been called”.这个程序闲置了很久,每次一遇到报错就懒得看了,终于在24年新年最后一天把这个问题解决了。
原因出在这个方法:
input_shape = self._model.get_input_shape_at(0)
或
self.feature_extractor.get_output_shape_at(-1)
get_input_shape_at()应该是在不同的版本不兼容,将其改成
input_shape = self._model.input_shape
self.feature_extractor.output_shape
就可以成功运行了