# -*- coding: utf-8 -*-
"""
Created on Thu Dec 20 16:20:43 2018

@author: 1
"""
# coding:utf-8
# 两种方式计算平均值
import numpy as np

f = open("HG_loss(64_0.08_102398_95%_1000).txt","r")
content = f.read()
f.close()
all_nums = [float(eval(line)[-1]) for line in content.split("\n")]
print(np.mean(all_nums)) # 使用numpy库直接求数组平均值
print(sum(all_nums)/len(all_nums)) #自己计算平均值

 

posted on 2019-02-25 11:48  Manuel  阅读(315)  评论(0编辑  收藏  举报