【问题标题】:how to train model with batches如何批量训练模型
【发布时间】:2019-04-02 16:38:15
【问题描述】:

我在 python 中尝试 yolo 模型。 为了处理数据和注释,我分批获取数据。

batchsize = 50

#boxList= []
#boxArr = np.empty(shape = (0,26,5))
for i in range(0, len(box_list), batchsize):
    boxList = box_list[i:i+batchsize]
    imagesList = image_list[i:i+batchsize]

    #to convert the annotation from VOC format
    convertedBox = np.array([np.array(get_boxes_for_id(box_l)) for box_l in boxList])

    #pre-process on image and annotaion
    image_data, boxes = process_input_data(imagesList,max_boxes,convertedBox)
    boxes = np.array(list(itertools.chain.from_iterable(boxes)))
    detectors_mask, matching_true_boxes = get_detector_mask(boxes, anchors)

在此之后,我想将我的数据传递给模型进行训练。 当我附加列表时,由于数组大小,它会出现内存错误。 当我附加数组时,由于形状而出现维度错误。

如何训练数据以及我应该使用什么 model.fit() 或 model.train_on_batch()

【问题讨论】:

    标签: python tensorflow image-processing keras object-detection


    【解决方案1】:

    如果您使用 Keras 用一堆图像训练您的模型,您可以使用训练生成器和验证生成器,您所要做的就是将您的图像放在相应的类文件夹中。看一个示例代码。也看看这个链接也许它可以帮助你https://keras.io/preprocessing/image/。我希望我已经回答了你的问题,除非我不明白

    【讨论】:

    • 我想在将数据传递给训练之前对数据进行预处理并应用自定义函数。应用两个自定义函数后,我想批量传递数据进行训练
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-11
    • 1970-01-01
    • 2021-05-22
    • 2018-02-20
    • 1970-01-01
    • 2017-10-12
    相关资源
    最近更新 更多