logo
Loading...

torchsummary 報錯;argument 'size' must be tuple of ints, but found element of type Tensor at pos 2 - Cupoy

在執行課程練習時有出現以下的錯誤可以請問大概會是甚麼出狀況嗎?

Day8

torchsummary 報錯;argument 'size' must be tuple of ints, but found element of type Tensor at pos 2

2021/01/15 下午 10:51
PyTorch 模型修改與特定層擷取
Even Pan
觀看數:508
回答數:3
收藏數:0
Day8

在執行課程練習時有出現以下的錯誤 可以請問大概會是甚麼出狀況嗎? ![image](http://kwassistfile.cupoy.com/000001770685EF95000000186375706F795F72656C656173655155455354/1610598311742/large)

回答列表

  • 2021/01/15 下午 11:08
    Even Pan
    贊同數:0
    不贊同數:0
    留言數:0

    當我使用 resnet 建議的input shape (3, 224, 224)並且將model後面多掛一個.to(decive)時可以成功 ![image](http://kwassistfile.cupoy.com/000001770696668D000000156375706F795F72656C65617365414E53/1610598311743/large)

  • 2021/01/23 上午 02:26
    張維元 (WeiYuan)
    贊同數:0
    不贊同數:0
    留言數:0

    嗨,你好
    應該是資料輸入不符合格式。

    嗨,你好,我是維元,持續在不同的平台發表對 #資料科學、 #網頁開發 或 #軟體職涯 相關的文章。如果對於內文有疑問都歡迎與我們進一步的交流,都可以追蹤我的 Facebook技術部落格 ,也會不定時的舉辦分享活動,一起來玩玩吧 ヽ(●´∀`●)ノ

  • 2021/03/08 下午 05:10
    魏培峰
    贊同數:0
    不贊同數:0
    留言數:0

    由torchsummary的說明文件可知,其輸入的參數為 summary(model, input_size, batch_size=-1, device='cuda') 而 torch.randn(1, 3, 128, 128)為產生1筆 3x128x128的 tensor,並不是 input_size,故要改成 input_.shape[1:] summary(model, input_.shape[1:] ,device='cpu') 即可跑出 另外,可試者調整 batch_size,這不會影響Total params,但會影響Estimated Total Size 至於 device='cuda' or 'cpu'。因為沒有cuda,所以不確定有什麼影響