国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

【解決問題】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton

這篇具有很好參考價(jià)值的文章主要介紹了【解決問題】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

一、錯(cuò)誤1

Can't get attribute 'SPPF' on <module 'models.common' from 'D:\\Pycharm\\Code\\yolov5-5.0\\models\\common.py'>

解決方案1

你可以去github上,這兒我用的是YOLOv5.5的版本,就去Tags6里面的model/common.py里面去找到這個(gè)SPPF的類,把它拷過來到你這個(gè)Tags5的model/common.py里面,這樣你的代碼就也有這個(gè)類了,還要引入一個(gè)warnings包就行了

【解決問題】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton,python,pytorch
點(diǎn)開common.py文件

import warnings
class SPPF(nn.Module):
    # Spatial Pyramid Pooling - Fast (SPPF) layer for YOLOv5 by Glenn Jocher
    def __init__(self, c1, c2, k=5):  # equivalent to SPP(k=(5, 9, 13))
        super().__init__()
        c_ = c1 // 2  # hidden channels
        self.cv1 = Conv(c1, c_, 1, 1)
        self.cv2 = Conv(c_ * 4, c2, 1, 1)
        self.m = nn.MaxPool2d(kernel_size=k, stride=1, padding=k // 2)

    def forward(self, x):
        x = self.cv1(x)
        with warnings.catch_warnings():
            warnings.simplefilter('ignore')  # suppress torch 1.9.0 max_pool2d() warning
            y1 = self.m(x)
            y2 = self.m(y1)
            return self.cv2(torch.cat([x, y1, y2, self.m(y2)], 1))

將這個(gè)復(fù)制到對應(yīng)的類就行了。

二、 錯(cuò)誤2

剛解決了上一個(gè)問題,結(jié)果又出現(xiàn)了問題,我也很崩潰,差了半天,也沒有找到解決辦法,最終,我找到了,哈哈,讓我笑一會?。?!下面看錯(cuò)誤:

RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton

解決方案2:

【解決問題】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton,python,pytorch
注意看這兩個(gè)是否對應(yīng):
【解決問題】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton,python,pytorch
因?yàn)槲疫\(yùn)行代碼的是后模型沒有下載下來,所以自己去github上下載的模型,然后出錯(cuò)了,就是模型錯(cuò)了,這兒給出地址:
https://github.com/ultralytics/yolov5/releases/download/v5.0/yolov5s.pt
下載到【解決問題】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton,python,pytorch
如圖同級目錄下就行了,然后就可以運(yùn)行了!文章來源地址http://www.zghlxwxcb.cn/news/detail-601100.html

到了這里,關(guān)于【解決問題】RuntimeError: The size of tensor a (80) must match the size of tensor b (56) at non-singleton的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • DataLoader問題解決:RuntimeError: stack expects each tensor to be equal size, but got [3, 200, 200]entry1

    DataLoader問題解決:RuntimeError: stack expects each tensor to be equal size, but got [3, 200, 200]entry1

    ? ? ? ? 最近,在數(shù)據(jù)集處理并載入DataLoader進(jìn)行訓(xùn)練的時(shí)候出現(xiàn)了問題: ? ? ? ? 我看了一下,大意就是維度也就是通道數(shù)不匹配,所以我覺得應(yīng)該是數(shù)據(jù)集圖片出現(xiàn)了問題。以下是我的普通數(shù)據(jù)集處理代碼: ? ? ? ? ? 我一張一張圖片放入DataLoader,然后按順序一張一張的

    2023年04月25日
    瀏覽(19)
  • 成功解決RuntimeError: batch2 must be a 3D tensor

    成功解決RuntimeError: batch2 must be a 3D tensor

    成功解決RuntimeError: batch2 must be a 3D tensor。 在深度學(xué)習(xí)的世界中,張量是構(gòu)建一切的核心。它們是數(shù)據(jù)的容器,是模型訓(xùn)練的基石。然而,當(dāng)我們嘗試使用 torch.bmm() 函數(shù)進(jìn)行批量矩陣乘法時(shí),可能會遇到一個(gè)常見的錯(cuò)誤:“RuntimeError: batch2 must be a 3D tensor”。這個(gè)錯(cuò)誤提示似乎

    2024年02月22日
    瀏覽(47)
  • RuntimeError: Given groups=1, weight of size [14, 464, 1, 1], expected input問題解決

    BUG解決 :RuntimeError: Given groups=1, weight of size [14, 464, 1, 1], expected input[16, 116, 56, 1] to have 464 channels, but got 116 channels instead 首選說一下這個(gè)問題,這個(gè)問題提示想要得到的是464個(gè)通道數(shù)但是實(shí)際上得到的是116個(gè)通道。 例如我給某個(gè)深度學(xué)習(xí)網(wǎng)絡(luò)中加CBAM注意力集中機(jī)制,具體可參

    2023年04月08日
    瀏覽(18)
  • RuntimeError: mat1 dim 1 must match mat2 dim 0 解決方法

    RuntimeError: mat1 dim 1 must match mat2 dim 0 解決方法

    RuntimeError: mat1 dim 1 must match mat2 dim 0 這個(gè)錯(cuò)誤的大概意思是:矩陣mat1 的第二維度要與mat2的第一維度不匹配 在新增別的數(shù)據(jù)集進(jìn)行訓(xùn)練時(shí)報(bào)當(dāng)前錯(cuò)誤,原因是輸入的圖像大小與之前不一樣,這是新手在學(xué)習(xí)時(shí)常會遇到的問題。 先看報(bào)錯(cuò)信息,確定報(bào)錯(cuò)位置 我的這個(gè)代碼是

    2024年02月15日
    瀏覽(22)
  • error: (-209:Sizes of input arguments do not match) The operation is neither ‘a(chǎn)rray op array‘ (where

    error: (-209:Sizes of input arguments do not match) The operation is neither ‘a(chǎn)rray op array‘ (where

    作者:非妃是公主 專欄:《計(jì)算機(jī)視覺》 個(gè)性簽:順境不惰,逆境不餒,以心制境,萬事可成。——曾國藩 Cannot find reference ‘imread‘ in ‘ init .py‘ error: (-209:Sizes of input arguments do not match) The operation is neither ‘a(chǎn)rray op array‘ (where cs231n-2022-01 Assignments1-numpy的使用 ModuleNotFound

    2024年02月11日
    瀏覽(18)
  • 【解決】RuntimeError: Boolean value of Tensor with more than one value is ambiguous

    在用pytorch進(jìn)行損失函數(shù)計(jì)算時(shí),報(bào)錯(cuò)誤: 翻譯過來就是說: 具有多個(gè)值的張量的布爾值不明確? 我是這報(bào)錯(cuò): 啥意思?,你問我,我也不知道呀!、、、 ?錯(cuò)誤原因分析: 其實(shí)是,因?yàn)槲覔p失函數(shù)調(diào)用時(shí)沒有初始化,所以導(dǎo)致報(bào)錯(cuò) 其實(shí)我是初始化了,但是因?yàn)闆]有+(),

    2024年02月16日
    瀏覽(19)
  • RuntimeError: stack expects each tensor to be equal size ??

    RuntimeError: stack expects each tensor to be equal size, but got [1200, 1200, 3] at entry 0 and [1200, 1344, 3] at entry 1 pytorch 數(shù)據(jù)處理錯(cuò)誤, 網(wǎng)上的各種方法都試過了 1: 檢查過數(shù)據(jù)的輸入通道是3, 標(biāo)簽是1,但是輸入的大小尺寸不同 2: 進(jìn)行如下方法也不行?。?:3: bs=1,不報(bào)錯(cuò),bs1 報(bào)錯(cuò) 4: bug 未解

    2024年02月01日
    瀏覽(30)
  • 成功解決使用BCEWithLogitsLoss時(shí)ValueError: Target size (torch.Size([4])) must be the same as input size (to

    成功解決使用BCEWithLogitsLoss時(shí)ValueError: Target size (torch.Size([4])) must be the same as input size (torch.Size([4, 1])) ?? 個(gè)人主頁:高斯小哥 ?? 高質(zhì)量專欄:Matplotlib之旅:零基礎(chǔ)精通數(shù)據(jù)可視化、Python基礎(chǔ)【高質(zhì)量合集】、PyTorch零基礎(chǔ)入門教程?? 希望得到您的訂閱和支持~ ?? 創(chuàng)作高質(zhì)量

    2024年03月11日
    瀏覽(90)
  • 【報(bào)錯(cuò)處理】RuntimeError: input.size(-1) must be equal to input_size. Expected 5, got 21

    1、 原因 : 使用view時(shí)維度指定錯(cuò)誤,LSTM(input,(h0,c0)) 指定batch_first=True?后,input就是(batch_size,seq_len,input_size)否則為input(seq_len, batch, input_size) 2、原因:并不是rnn的錯(cuò)誤,而是因?yàn)橄乱缓瘮?shù)的輸入和這一層輸出維度不一樣,對照維度信息和尺寸信息修改即可。 推薦報(bào)錯(cuò)解決方

    2024年02月16日
    瀏覽(19)
  • RuntimeError: stack expects each tensor to be equal size, but got at entry

    RuntimeError: stack expects each tensor to be equal size, but got at entry

    參考鏈接:??????解決Pytorch dataloader時(shí)報(bào)錯(cuò)每個(gè)tensor維度不一樣的問題_python_腳本之家 記錄一下自己遇到的bug: 問題描述:? 問題分析: torch.stack(batch, 0, out=out)出錯(cuò),原因可能是: 同一個(gè)batch的數(shù)據(jù)圖片的維度(H, W, C)要相同(可以見官方文檔:其shape必須一致) 問

    2024年02月15日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包