1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        Pytorch 網(wǎng)絡(luò)結(jié)構(gòu)可視化

        共 3196字,需瀏覽 7分鐘

         ·

        2021-05-16 07:07

        點(diǎn)擊上方小白學(xué)視覺”,選擇加"星標(biāo)"或“置頂

        重磅干貨,第一時間送達(dá)

        本文轉(zhuǎn)自:深度學(xué)習(xí)這件小事

        安裝


        可以通過以下的命令進(jìn)行安裝

        conda install pytorch-nightly -c pytorch
        conda install graphviz
        conda install torchvision
        conda install tensorwatch

        本教程基于以下的版本:

        torchvision.__version__   '0.2.1'
        torch.__version__ '1.2.0.dev20190610'
        sys.version '3.6.8 |Anaconda custom (64-bit)| (default, Dec 30 2018, 01:22:34)
        [GCC 7.3.0]'
        載入庫


        import sys
        import torch
        import tensorwatch as tw
        import torchvision.models
        網(wǎng)絡(luò)結(jié)構(gòu)可視化


        alexnet_model = torchvision.models.alexnet()
        tw.draw_model(alexnet_model, [1, 3, 224, 224])

        載入alexnet,draw_model函數(shù)需要傳入三個參數(shù),第一個為model,第二個參數(shù)為input_shape,第三個參數(shù)為orientation,可以選擇'LR'或者'TB',分別代表左右布局與上下布局。

        在notebook中,執(zhí)行完上面的代碼會顯示如下的圖,將網(wǎng)絡(luò)的結(jié)構(gòu)及各個層的name和shape進(jìn)行了可視化。


        統(tǒng)計網(wǎng)絡(luò)參數(shù)


        可以通過model_stats方法統(tǒng)計各層的參數(shù)情況。

        tw.model_stats(alexnet_model, [1, 3, 224, 224])

        [MAdd]: Dropout is not supported!
        [Flops]: Dropout is not supported!
        [Memory]: Dropout is not supported!
        [MAdd]: Dropout is not supported!
        [Flops]: Dropout is not supported!
        [Memory]: Dropout is not supported!
        [MAdd]: Dropout is not supported!
        [Flops]: Dropout is not supported!
        [Memory]: Dropout is not supported!
        [MAdd]: Dropout is not supported!
        [Flops]: Dropout is not supported!
        [Memory]: Dropout is not supported!
        [MAdd]: Dropout is not supported!
        [Flops]: Dropout is not supported!
        [Memory]: Dropout is not supported!
        [MAdd]: Dropout is not supported!
        [Flops]: Dropout is not supported!
        [Memory]: Dropout is not supported!



        alexnet_model.features

        Sequential(
        (0): Conv2d(3, 64, kernel_size=(11, 11), stride=(4, 4), padding=(2, 2))
        (1): ReLU(inplace=True)
        (2): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
        (3): Conv2d(64, 192, kernel_size=(5, 5), stride=(1, 1), padding=(2, 2))
        (4): ReLU(inplace=True)
        (5): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
        (6): Conv2d(192, 384, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (7): ReLU(inplace=True)
        (8): Conv2d(384, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (9): ReLU(inplace=True)
        (10): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1))
        (11): ReLU(inplace=True)
        (12): MaxPool2d(kernel_size=3, stride=2, padding=0, dilation=1, ceil_mode=False)
        )

        alexnet_model.classifier

        Sequential(
        (0): Dropout(p=0.5)
        (1): Linear(in_features=9216, out_features=4096, bias=True)
        (2): ReLU(inplace=True)
        (3): Dropout(p=0.5)
        (4): Linear(in_features=4096, out_features=4096, bias=True)
        (5): ReLU(inplace=True)
        (6): Linear(in_features=4096, out_features=1000, bias=True)
        )

        考:

        https://github.com/microsoft/tensorwatch

        下載1:OpenCV-Contrib擴(kuò)展模塊中文版教程
        在「小白學(xué)視覺」公眾號后臺回復(fù):擴(kuò)展模塊中文教程,即可下載全網(wǎng)第一份OpenCV擴(kuò)展模塊教程中文版,涵蓋擴(kuò)展模塊安裝、SFM算法、立體視覺、目標(biāo)跟蹤、生物視覺、超分辨率處理等二十多章內(nèi)容。

        下載2:Python視覺實戰(zhàn)項目52講
        小白學(xué)視覺公眾號后臺回復(fù):Python視覺實戰(zhàn)項目,即可下載包括圖像分割、口罩檢測、車道線檢測、車輛計數(shù)、添加眼線、車牌識別、字符識別、情緒檢測、文本內(nèi)容提取、面部識別等31個視覺實戰(zhàn)項目,助力快速學(xué)校計算機(jī)視覺。

        下載3:OpenCV實戰(zhàn)項目20講
        小白學(xué)視覺公眾號后臺回復(fù):OpenCV實戰(zhàn)項目20講,即可下載含有20個基于OpenCV實現(xiàn)20個實戰(zhàn)項目,實現(xiàn)OpenCV學(xué)習(xí)進(jìn)階。

        交流群


        歡迎加入公眾號讀者群一起和同行交流,目前有SLAM、三維視覺、傳感器、自動駕駛、計算攝影、檢測、分割、識別、醫(yī)學(xué)影像、GAN、算法競賽等微信群(以后會逐漸細(xì)分),請掃描下面微信號加群,備注:”昵稱+學(xué)校/公司+研究方向“,例如:”張三 + 上海交大 + 視覺SLAM“。請按照格式備注,否則不予通過。添加成功后會根據(jù)研究方向邀請進(jìn)入相關(guān)微信群。請勿在群內(nèi)發(fā)送廣告,否則會請出群,謝謝理解~


        瀏覽 46
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報
        評論
        圖片
        表情
        推薦
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        分享
        舉報
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            亚洲AV无码久久久天堂成人 | 欧美乱伦第一页 | 国产伦精品一区二区三区视频我 | 骚屄影院| 人人妻人人澡人人爽久久av | 精品激情网 | 欧美日韩在线视频播放 | 在线小视频| 欧美精品中文字幕在线观看 | 777精品 |