我试图从一系列图像中创建一个数据集,以使用Tensorflow训练深度学习模型,但我遇到了标签问题。
我的目标是在每个图像中检测多个对象,所以我创建了这样的东西:
labels =
# Image 1
[
[100, 50], # Object 1 attributes (x, y)
[250, 100], # Object 2 attributes
],
# Image 2
[
[50, 60], # Object 1 attributes
[200, 70], # Object 2 attributes
[450, 40], # Object 3 attributes
],
...
]
字符串
我已经成功地训练了一个模型,当只有一个物体要检测时,但是当我尝试多个物体时,它就不行了。我试了这个:
dataset = tf.data.Dataset.from_tensor_slices((X, tf.ragged.constant(label)))
model = tf.keras.Sequential([
tfl.ZeroPadding2D(padding=(10, 10), input_shape=(535, 535, 4)),
tfl.Conv2D(32, (7, 7)),
tfl.BatchNormalization(axis=-1),
tfl.ReLU(),
tfl.MaxPool2D(),
tfl.Flatten(),
tfl.Dense(2, activation='linear')
])
model.compile(optimizer='adam', loss='mae', metrics=['mse', 'mae'])
Error:
TypeError: Some of the inputs are not tf.RaggedTensor. Input received: [tf.RaggedTensor(values=tf.RaggedTensor(values=Tensor("Cast_20:0", shape=(None,), dtype=float32), row_splits=Tensor("RaggedFromVariant/RaggedTensorFromVariant:1", shape=(None,), dtype=int64)), row_splits=Tensor("RaggedFromVariant/RaggedTensorFromVariant:0", shape=(None,), dtype=int64)), <tf.Tensor 'sequential_24/dense_24/BiasAdd:0' shape=(None, 2) dtype=float32>]
的数据
帮帮忙=)
1条答案
按热度按时间acruukt91#
你必须把我们标签的值放在字典里,这就可以了。
字符串