栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

从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]


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/662040.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号