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]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)