Tensorflow 2.2-gpu <br/>
pycharm
当我将batch_size选项1更改为它提供的任何数字时
tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot add tensor to the batch: number of elements does not match. Shapes are: [tensor]: [5], [batch]: [3]
原始代码没有什么特别的
def train():
print('train')
if isprint:print(tf.__version__)
batch_size= 2
images,boxes,labels,difficulties,new_boxes= PascalVOCDataset()
new_boxes = list(new_boxes)
boxes = tf.ragged.constant(boxes)
labels = tf.ragged.constant(labels)
new_boxes = tf.ragged.constant(new_boxes)
dataset = tf.data.Dataset.from_tensor_slices((images,new_boxes,labels))
run_train(dataset.map(resize_image_bbox, num_parallel_calls=tf.data.experimental.AUTOTUNE).batch(batch_size).prefetch(tf.data.experimental.AUTOTUNE))
image_shape-> (2, 300, 300, 3)
labels_shape-> (2, 2)
boxes_shape-> (2,)