test_all.py 文件源码

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

项目:ZOO-Attack 作者: huanzhang12 项目源码 文件源码
def show(img, name = "output.png"):
    """
    Show MNSIT digits in the console.
    """
    np.save(name, img)
    fig = np.around((img + 0.5)*255)
    fig = fig.astype(np.uint8).squeeze()
    pic = Image.fromarray(fig)
    # pic.resize((512,512), resample=PIL.Image.BICUBIC)
    pic.save(name)
    remap = "  .*#"+"#"*100
    img = (img.flatten()+.5)*3
    if len(img) != 784: return
    print("START")
    for i in range(28):
        print("".join([remap[int(round(x))] for x in img[i*28:i*28+28]]))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号