('throughput', '{:.2f}'.format(fps)), ]) if statistics: statistics.dump() print('Count: {} iterations'.format(iteration)) print('Duration: {:.2f} ms'.format(get_duration_in_milliseconds(total_duration_sec))) if MULTI_DEVICE_NAME not in device_name: print('Latency: {:.2f} ms'.format(latency_ms)) print('Throughput: {:.2f} FPS'.format(fps)) del exe_network next_step.step_id = 0 except Exception as e: logger.exception(e) if statistics: statistics.add_parameters(StatisticsReport.Category.EXECUTION_RESULTS, [ ('error', str(e)), ]) statistics.dump() if __name__ == "__main__": # ------------------------------ 1. Parsing and validating input arguments ------------------------------------- next_step() main(parse_args())
if args.enable_gpu: log_vecs = log_vecs.cuda(device=device, non_blocking=True) log_mask = log_mask.cuda(device=device, non_blocking=True) user_vecs = model.user_encoder( log_vecs, log_mask, user_log_mask=True).to(torch.device("cpu")).detach().numpy() for id, user_vec, news_vec in zip(impids, user_vecs, candidate_vec): score = np.dot(news_vec, user_vec) pred_rank = (np.argsort(np.argsort(score)[::-1]) + 1).tolist() f.write( str(id) + ' ' + '[' + ','.join([str(x) for x in pred_rank]) + ']' + '\n') f.close() zip_file = zipfile.ZipFile('prediction.zip', 'w') zip_file.write('prediction.txt') zip_file.close() os.remove('prediction.txt') if __name__ == "__main__": from parameters import parse_args setuplogger() args = parse_args() generate_submission(args)