如何批量训练模型 [英] how to train model with batches

查看:112
本文介绍了如何批量训练模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在python中尝试yolo模型. 要处理数据和注释,我要分批处理数据.

I trying yolo model in python. To process the data and annotation I'm taking the data in batches.

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)

此后,我想将我的数据传递给模型进行训练. 当我追加列表时,由于数组大小,它给出了内存错误. 当我追加数组时由于形状而导致尺寸错误.

after this, I want to pass my data to the model to train. when I append the list it gives memory error because of array size. and when i append array gives dimensionality error because of shape.

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

how can i train the data and what shoud i use model.fit() or model.train_on_batch()

推荐答案

如果您正在使用Keras通过一堆图像训练模型,则可以使用Train生成器和验证生成器,只需将图像放入那里有各自的班级文件夹.看一个示例代码.也请看一下此链接,也许它可以帮助您

If you are using Keras to Train your model with a bunch of Images you can use Train generator and validation generator, all you have to do is put your images in there respective class folders. look at a sample code . also take a look at this link maybe it may help you

这篇关于如何批量训练模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆