how to train model with batches

喜你入骨 提交于 2021-01-29 16:19:59

问题


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.

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


回答1:


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 https://keras.io/preprocessing/image/ . i hope i have answered your question unless i did not understand it



来源:https://stackoverflow.com/questions/53050723/how-to-train-model-with-batches

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!