从CSV加载图像和注释,并将fit_generator与多输出模型一起使用

从CSV加载图像和注释,并将fit_generator与多输出模型一起使用,第1张

从CSV加载图像和注释,并将fit_generator与多输出模型一起使用
def multi_output_generator(hdf5_file, nb_data, batch_size):    """ Generates batches of tensor image data in form of ==> x, [y1, y2, y3, y4, y5] for use in a multi-output Keras model.        # Arguments hdf5_file: the hdf5 file which contains the images and the annotations. nb_data: total number of samples saved in the array. batch_size: size of the batch to generate tensor image data for.        # Returns A five-output generator.    """    batches_list = list(range(int(ceil(float(nb_data) / batch_size))))    while True:        # loop over batches        for n, i in enumerate(batches_list): i_s = i * batch_size  # index of the first image in this batch i_e = min([(i + 1) * batch_size, nb_data])  # index of the last image in this batch x = hdf5_file["x_train"][i_s:i_e, ...] # read labels y1 = hdf5_file["y1"][i_s:i_e] y2 = hdf5_file["y2"][i_s:i_e] y3 = hdf5_file["y3"][i_s:i_e] y4 = hdf5_file["y4"][i_s:i_e] y5 = hdf5_file["y5"][i_s:i_e]        yield x, [y1, y2, y3, y4 ,y5]


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5663996.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存