AttributeError Traceback (most recent call last)
<ipython-input-74-d69bb71a2d56> in <module>
----> 1 yolo_outputs = yolo_head(yolo_model.output, anchors,len(class_names))
~Autonomous driving systemyad2kmodelskeras_yolo.py in yolo_head(feats,anchors, num_classes)
106 conv_width_index = K.flatten(K.transpose(conv_width_index))
107 conv_index = K.transpose(K.stack([conv_height_index, conv_width_index]))
--> 108 conv_index = K.reshape(conv_index, [1, conv_dims[0], conv_dims[1], 1, 2])
109 conv_index = K.cast(conv_index, K.dtype(feats))
110
c:users91884appdatalocalprogramspythonpython37libsite-packagestensorflowpythonutildispatch.py in wrapper(*args, **kwargs)
c:users91884appdatalocalprogramspythonpython37libsite-packagestensorflowpythonkerasbackend.py in dtype(x)
AttributeError: 'list' object has no attribute 'dtype'
我试图卸载我的tensorflow==2.3.1并安装tensorflow===1.15,但问题没有解决。是因为tensorflow版本还是代码中有一些错误,还是因为yolo.h5文件。
它与Tensorflow版本无关,只是由于行中的第二个参数:
conv_index = K.reshape(conv_index, [1, conv_dims[0], conv_dims[1], 1, 2])
你必须将列表转换为张量。例如:
conv_index = K.reshape(conv_index, tf.constant([[1, conv_dims[0], conv_dims[1]), 1, 2]])