def predictions_from_csv(fh, max_length):
"""
Loads single model predictions from a csv file where lines may differ in length
:param fh: file handle to the csv file
:return: list of numpy arrays representing the predictions of individual examples
"""
preds = list()
lineN = 0
for line in fh:
lineN += 1
pred_line = numpy.fromstring(line, sep=', ')
if (args.trim_zeros):
# If different batch sizes are used for the fused models, the prediction vectors need to be adjusted
pred_line, max_length = adjust_length(pred_line, lineN, max_length)
preds.append(pred_line)
return preds, max_length
评论列表
文章目录