make_pca.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:melanoma-transfer 作者: learningtitans 项目源码 文件源码
def std(files, batch_size=128):
    s = np.zeros(3)
    s2 = np.zeros(3)
    shape = None
    for i in range(0, len(files), batch_size):
        print("done with {:>3} / {} images".format(i, len(files)))
        images = np.array(data.load_image(files[i : i + batch_size]),
                          dtype=np.float64)
        shape = images.shape
        s += images.sum(axis=(0, 2, 3))
        s2 += np.power(images, 2).sum(axis=(0, 2, 3))
    n = len(files) * shape[2] * shape[3]
    var = (s2 - s**2.0 / n) / (n - 1)

    print('mean')
    print((s / n).astype(np.float32))
    print('std')
    print(np.sqrt(var))
    #return np.sqrt(var)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号