博客
关于我
pytorch可视化 resnet50特征图
阅读量:82 次
发布时间:2019-02-26

本文共 1466 字,大约阅读时间需要 4 分钟。

ResNet50??????PyTorch???????? inference ??

????????ResNet50?????????????????????????????????????????????????????????????PyTorch??????ResNet50???????????????

??????

ResNet50??????????????????????Residual Blocks??????????????????

  • ????[1, 3, 224, 224]????????????????
  • ???1?[1, 64, 112, 112]
  • ?????1?[1, 64, 112, 112]
  • ?????ReLU?
  • ??????[1, 64, 56, 56]
  • ?1?[1, 256, 56, 56]
  • ?2?[1, 512, 28, 28]
  • ?3?[1, 1024, 14, 14]
  • ?4?[1, 2048, 7, 7]
  • ??????[1, 2048]
  • ?????[1, 1000]

???????

??? inference ??????????????????PyTorch?????????????????????????????????????

  • ??????PyTorch??????????ResNet50???
  • ????????????????????????
  • ???????????????????????????????
  • ??????

    ??????????????????

    import cv2
    import time
    import os
    import matplotlib.pyplot as plt
    import torch
    from torch import nn
    import torchvision.models as models
    import torchvision.transforms as transforms
    savepath = 'vis_resnet50/features_elephant'
    if not os.path.exists(savepath):
    os.mkdir(savepath)
    def draw_features(width, height, x, savename):
    tic = time.time()
    fig = plt.figure(figsize=(16, 16))
    fig.subplots_adjust(left=0.05, right=0.95, bottom=0.05, top=0.95, wspace=0.05)
    # ??????????
    plt.imshow(x)
    plt.savefig(os.path.join(savepath, savename))
    plt.close()
    toc = time.time()
    print(f"?????{toc - tic:.2f}?")

    ????

    • ?????ResNet50?????????????????[1, 3, 224, 224]?
    • ??????????PyTorch???????????????
    • ????????????????????????????????????????

    ????????????????ResNet50??????????????????????????

    转载地址:http://taxz.baihongyu.com/

    你可能感兴趣的文章
    NodeJs单元测试之 API性能测试
    查看>>
    nodejs图片转换字节保存
    查看>>
    NodeJs学习笔记001--npm换源
    查看>>
    Nodejs教程09:实现一个带接口请求的简单服务器
    查看>>
    Nodejs简介以及Windows上安装Nodejs
    查看>>
    nodejs系列之express
    查看>>
    nodejs配置express服务器,运行自动打开浏览器
    查看>>
    Node中的Http模块和Url模块的使用
    查看>>
    Node入门之创建第一个HelloNode
    查看>>
    Node出错导致运行崩溃的解决方案
    查看>>
    node安装及配置之windows版
    查看>>
    Node提示:error code Z_BUF_ERROR,error error -5,error zlib:unexpected end of file
    查看>>
    NOIp2005 过河
    查看>>
    NOIp模拟赛二十九
    查看>>
    NOPI读取Excel
    查看>>
    NoSQL&MongoDB
    查看>>
    NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
    查看>>
    npm error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”。要解决此问题,1) 安装
    查看>>
    npm install digital envelope routines::unsupported解决方法
    查看>>
    npm install 报错 ERR_SOCKET_TIMEOUT 的解决方法
    查看>>