pytorch中dataloader中报错(RuntimeError: each element in list of batch)解决方法

2024-02-04 16:06:00 by wst

数据处理

       在进行数据训练的时候,首先要载入数据集。但是如果处理不好,载入数据也会报错,这里我就遇到错误:RuntimeError: each element in list of batch should be of equal size

下面给出解决方法,直接上代码:


from torch.utils.data import DataLoader
import webdataset as wds
import json


def test_dataloader():
    "test"
    def my_decoder(key, value):
        if not key.endswith(".jpg"):
            return None
        assert isinstance(value, bytes)
        return value

    url = "/home/wst/dataset/v1_res/{00000..00022}.tar"

    def mycollate(item):
        if len(item) != 128:
            return item
        print("type:", type(item))
        return len(item)
    dataset = wds.WebDataset(url).shuffle(1000).decode(my_decoder)
    dataloader = DataLoader(dataset, num_workers=4, shuffle=False, batch_size=128, collate_fn=mycollate)
    for sample in dataloader:
        print(sample)

if __name__ == "__main__":
    test_dataloader()

注意其中的mycollate函数,如果dataloader中不传入collate_fn=mycollate,则会报错,因为每个批次的数据量不一致。

这个代码如果要用,记得改改哦。

 


Comments(133) Add Your Comment

Svsqnt
atorvastatin 10mg usa <a href="https://lipiws.top/">atorvastatin 10mg generic</a> atorvastatin 10mg for sale
Zhczis
baycip pill - <a href="https://cipropro.top/keflexcapsule/">cephalexin 125mg pills</a> cheap amoxiclav
Yktada
baycip for sale online - <a href="https://metroagyl.top/azithromycin/">buy augmentin sale</a> buy generic augmentin 375mg
Fwsfpy
order ciprofloxacin pill - <a href="https://septrim.top/doryx/">buy doxycycline sale</a> order generic erythromycin
Sajekp
buy generic flagyl - <a href="https://metroagyl.top/azithromycin/">generic zithromax 250mg</a> brand azithromycin 250mg
Currlx
ivermectin 12 mg without prescription - <a href="https://keflexin.top/">order ciprofloxacin 500mg</a> tetracycline 250mg canada
Zlddve
how to buy valacyclovir - <a href="https://gnantiviralp.com/diltiazem/">diltiazem price</a> buy zovirax pill
Jtbqfs
order generic ampicillin <a href="https://ampiacil.top/">order ampicillin for sale</a> cheap amoxicillin without prescription
Bryzbf
purchase flagyl online - <a href="https://metroagyl.top/keflexcapsule/">buy amoxicillin paypal</a> purchase zithromax online cheap
Pwaztd
lasix 40mg ca - <a href="https://antipathogenc.com/minipressm/">minipress drug</a> order captopril
Hylnef
metformin drug - <a href="https://gnantiacidity.com/baycip/">purchase baycip generic</a> buy lincomycin tablets
Swouwi
order zidovudine sale - <a href="https://canadiangnp.com/allopurinol/">order allopurinol without prescription</a> order zyloprim 100mg generic
Aqhmru
clozaril 100mg brand - <a href="https://genonlinep.com/altace/">order tritace generic</a> pepcid 40mg over the counter
Bsgnre
buy cheap clomipramine - <a href="https://antdeponline.com/sinequan/">order doxepin generic</a> doxepin 25mg generic
Atnwcl
order quetiapine 100mg without prescription - <a href="https://gnkantdepres.com/luvox/">buy fluvoxamine 50mg generic</a> eskalith tablets
Uqoxfp
hydroxyzine online buy - <a href="https://antdepls.com/prozac/">prozac canada</a> buy endep 25mg generic
Hqnmdb
buy augmentin 625mg sale - <a href="https://atbioinfo.com/ampicillin/">ampicillin ca</a> purchase baycip online cheap
Sctnki
buy amoxil tablets - <a href="https://atbioxotc.com/cephalexin/">generic cephalexin</a> baycip over the counter
Jzxbtl
zithromax ca - <a href="https://gncatbp.com/aciprofloxacin/">buy ciprofloxacin 500mg generic</a> buy ciplox sale
Ktmyib
buy generic cleocin online - <a href="https://cadbiot.com/doxycycline/">monodox order</a> where to buy chloramphenicol without a prescription
Prmgzu
ivermectin 12 mg tablets - <a href="https://antibpl.com/">ivermectin human</a> buy cefaclor 500mg pill
Mbzjlp
order albuterol 4mg generic - <a href="https://antxallergic.com/dftheo-24/">theophylline 400 mg for sale</a> order theo-24 Cr online cheap
Dnduag
order medrol generic - <a href="https://ntallegpl.com/loratadine/">order claritin 10mg online</a> where to buy astelin without a prescription
Doampc
oral clarinex 5mg - <a href="https://rxtallerg.com/flixotidespray/">purchase flixotide nasal spray</a> buy ventolin pills for sale
Djhqmx
buy micronase 5mg online - <a href="https://prodeprpl.com/glipizide10/">generic glipizide 5mg</a> buy dapagliflozin 10mg pills
Gqmdkp
purchase glucophage online - <a href="https://arxdepress.com/sitagliptin50/">buy cheap sitagliptin</a> buy acarbose pills
Elyqwh
buy prandin 1mg without prescription - <a href="https://depressinfo.com/jardiance25/">empagliflozin 25mg without prescription</a> jardiance 10mg uk
Ieumfr
semaglutide order - <a href="https://infodeppl.com/glucovance5/">buy generic glucovance online</a> DDAVP online buy
Toakwn
generic lamisil 250mg - <a href="https://treatfungusx.com/fulvicin250mg/">griseofulvin 250mg ca</a> purchase griseofulvin pill
Vpphjy
purchase ketoconazole online cheap - <a href="https://antifungusrp.com/">nizoral canada</a> buy sporanox no prescription
Ppbdoo
famvir over the counter - <a href="https://amvinherpes.com/gnvalaciclovir/">buy valcivir 500mg online</a> order generic valcivir
Wdzneq
lanoxin 250mg ca - <a href="https://blpressureok.com/furosemidediuret/">buy lasix pills diuretic</a> order lasix 40mg for sale
Iolnqk
buy generic metoprolol - <a href="https://bloodpresspl.com/propranolol/">cheap propranolol</a> adalat 30mg brand
Lhinju
purchase hydrochlorothiazide generic - <a href="https://norvapril.com/lisinopril/">lisinopril cost</a> bisoprolol drug
Bfqbbx
nitroglycerin online order - <a href="https://nitroproxl.com/">purchase nitroglycerin generic</a> valsartan 160mg us
Eixoya
simvastatin ford - <a href="https://canescholest.com/">simvastatin preparation</a> atorvastatin act
Cnqrtd
rosuvastatin online auditor - <a href="https://antcholesterol.com/pravastatin/">pravastatin buy cross</a> caduet online farm
Dpkkne
viagra professional fresh - <a href="https://edsildps.com/">viagra professional tonight</a> levitra oral jelly code
Voitel
priligy somehow - <a href="https://promedprili.com/fildena/">fildena advice</a> cialis with dapoxetine grand
Elrgfg
cenforce online coin - <a href="https://xcenforcem.com/brandviagrasildenafil/">brand viagra conversation</a> brand viagra online wall
Dywyic
brand cialis young - <a href="https://probrandtad.com/viagrasofttabs/">viagra soft tabs about</a> penisole board
Qvktyr
brand cialis pot - <a href="https://probrandtad.com/forzestpills/">forzest interest</a> penisole business
Fpuake
cialis soft tabs online death - <a href="https://supervalip.com/levitrasoft/">levitra soft water</a> viagra oral jelly anyhow
Yoidjl
cialis soft tabs rob - <a href="https://supervalip.com/valifonline/">valif pills system</a> viagra oral jelly tell
Lntrev
dapoxetine await - <a href="https://promedprili.com/suhagra/">suhagra happy</a> cialis with dapoxetine check
Pfbylo
cenforce online officer - <a href="https://xcenforcem.com/tadaciptadalafil/">tadacip pills reward</a> brand viagra pills arise
Nepenu
asthma treatment cure - <a href="https://bsasthmaps.com/">asthma treatment scrap</a> asthma treatment holiday
Zzlgcq
acne medication loom - <a href="https://placnemedx.com/">acne medication tradition</a> acne treatment squat
Ktwzac
prostatitis treatment person - <a href="https://xprosttreat.com/">prostatitis treatment tournament</a> pills for treat prostatitis bone
Aewhow
treatment for uti often - <a href="https://amenahealthp.com/">uti antibiotics reflect</a> treatment for uti force
Mrgsaa
claritin pills deserve - <a href="https://clatadine.top/">claritin pills kneel</a> claritin spirit
Uqqsah
valtrex online wound - <a href="https://gnantiviralp.com/">valacyclovir glow</a> valacyclovir along
Vbdllk
dapoxetine would - <a href="https://prilixgn.top/">priligy put</a> dapoxetine awkward
Xrkujs
claritin pills opposite - <a href="https://clatadine.top/">loratadine scarlet</a> claritin pills passe
Jsseem
ascorbic acid pardon - <a href="https://ascxacid.com/">ascorbic acid wing</a> ascorbic acid pretend
Iyfdwa
promethazine snore - <a href="https://prohnrg.com/">promethazine underground</a> promethazine fight
Fosbsc
biaxin pills bound - <a href="https://gastropls.com/albendazole400/">albenza president</a> cytotec hollow
Ldjshp
fludrocortisone pills crouch - <a href="https://gastroplusp.com/nexesomeprazole/">nexium pills nothing</a> lansoprazole pills permission
Eofpyp
buy generic rabeprazole for sale - <a href="https://gastrointesl.com/">buy aciphex pills</a> buy generic motilium online
Ccaedw
bisacodyl generic - <a href="https://gastroinfop.com/">dulcolax sale</a> liv52 usa
Venvsd
brand hydroquinone - <a href="https://dupsteron.com/">pill duphaston 10 mg</a> duphaston usa
Knoszz
order cotrimoxazole sale - <a href="https://cotrioxazo.com/">cheap bactrim</a> brand tobrex
Tzhyoz
griseofulvin 250 mg uk - <a href="https://gemfilopi.com/">gemfibrozil 300 mg uk</a> brand lopid 300 mg
Xakstp
buy cheap forxiga - <a href="https://sineqpin.com/">order sinequan 75mg generic</a> order precose 25mg generic
Imdwiw
purchase dramamine pills - <a href="https://prasilx.com/">buy prasugrel 10mg pill</a> risedronate 35mg generic
Mahpqv
enalapril canada - <a href="https://doxapisin.com/">where can i buy doxazosin</a> buy zovirax eye drops for sale
Hydnuu
monograph price - <a href="https://etodograph.com/">buy etodolac 600mg for sale</a> brand cilostazol 100 mg
Irittf
order feldene 20mg - <a href="https://feldexicam.com/">piroxicam usa</a> buy rivastigmine 6mg online cheap
Rfuyam
piracetam 800 mg brand - <a href="https://nootquin.com/levofloxacin/">order levofloxacin 500mg generic</a> where to buy sinemet without a prescription
Kegicb
buy hydroxyurea tablets - <a href="https://hydroydrinfo.com/trecatorsc/">trecator sc online order</a> buy robaxin 500mg online
Hhamaw
buy divalproex 500mg online - <a href="https://adepamox.com/amiodarone/">order cordarone 200mg online</a> purchase topiramate online cheap
Qnluxr
disopyramide phosphate tablet - <a href="https://anorpica.com/pregabal/">buy pregabalin 75mg</a> chlorpromazine 50 mg pills
Prpqqt
order spironolactone 100mg generic - <a href="https://aldantinep.com/carbamazepine/">buy cheap carbamazepine</a> order generic naltrexone 50mg
Zulseu
cyclophosphamide online order - <a href="https://cycloxalp.com/dimenhydrinate/">dimenhydrinate uk</a> cheap vastarel generic
Fvvlsk
flexeril cost - <a href="https://abflequine.com/">buy cyclobenzaprine generic</a> buy vasotec no prescription
Clihex
cheap zofran - <a href="https://azofarininfo.com/ropinirole/">requip 2mg drug</a> purchase ropinirole generic
Dbqcqh
cheap ascorbic acid 500 mg - <a href="https://mdacidinfo.com/ferroussulfate/">buy ferrous 100 mg pills</a> buy prochlorperazine sale
Nwerff
where can i order durex gel - <a href="https://xalaplinfo.com/latanoprosteyedrops/">purchase latanoprost for sale</a> purchase zovirax generic
Miipvj
rogaine price - <a href="https://hairlossmedinfo.com/finasteridepros/">order generic proscar</a> order proscar 5mg pill
Itjnrq
leflunomide oral - <a href="https://infohealthybones.com/risedronate/">actonel 35mg cost</a> cartidin cheap
Nabzwa
buy verapamil 120mg sale - <a href="https://infoheartdisea.com/">verapamil 240mg generic</a> buy tenoretic pills for sale
Hwlueu
tenormin 100mg canada - <a href="https://heartmedinfox.com/clopidogrel/">buy clopidogrel medication</a> order coreg 25mg generic
Ygvqvb
buy atorlip generic - <a href="https://infoxheartmed.com/enalapril/">buy enalapril pills</a> purchase nebivolol sale
Hkceii
purchase gasex without prescription - <a href="https://herbalinfomez.com/">how to buy gasex</a> buy diabecon pills for sale
Dtohra
lasuna online buy - <a href="https://infoherbalmz.com/">buy lasuna without prescription</a> purchase himcolin online
Jreoly
where can i buy noroxin - <a href="https://gmenshth.com/">norfloxacin buy online</a> order confido online cheap
Drhatt
finasteride where to buy - <a href="https://finmenura.com/doxazosin/">generic cardura</a> buy alfuzosin 10 mg pills
Owuwnc
cost speman - <a href="https://spmensht.com/">speman canada</a> cheap fincar online
Volnoq
order terazosin generic - <a href="https://hymenmax.com/">buy hytrin 1mg generic</a> order dapoxetine 60mg online cheap
Zntybg
oxcarbazepine brand - <a href="https://trileoxine.com/levothyroxine/">buy levothyroxine generic</a> cheap levothyroxine sale
Fyugfd
purchase cyclosporine - <a href="https://asimusxate.com/gloperba/">generic colchicine 0.5mg</a> order generic colcrys
Hhqyze
order duphalac generic - <a href="https://duphalinfo.com/">lactulose over the counter</a> order betahistine 16 mg for sale
Fvnplu
calcort order online - <a href="https://lazacort.com/brimonidine/">buy alphagan sale</a> brimonidine over the counter
Fdqpni
purchase besivance online cheap - <a href="https://besifxcist.com/sildamax/">order sildamax pill</a> where to buy sildamax without a prescription
Uxhhvl
order neurontin 100mg pills - <a href="https://aneutrin.com/sulfasalazine/">buy generic azulfidine 500mg</a> order sulfasalazine generic
Afddci
buy probenecid pills - <a href="https://bendoltol.com/monograph/">buy monograph cheap</a> order carbamazepine 200mg online
Cqdghb
buy celecoxib pills for sale - <a href="https://celespas.com/">celecoxib buy online</a> buy cheap indocin
Vlxnqu
mebeverine over the counter - <a href="https://coloxia.com/pletal/">cilostazol without prescription</a> purchase pletal pills
Vhlana
buy generic diclofenac - <a href="https://dicloltarin.com/">cambia tablet</a> aspirin 75mg canada
Cndrer
order generic rumalaya - <a href="https://rumaxtol.com/amitriptyline/">purchase endep generic</a> buy generic amitriptyline 10mg
Nodsfv
buy mestinon 60 mg without prescription - <a href="https://mestonsx.com/azathioprine/">buy imuran 25mg online</a> imuran us
Drryhj
buy voveran paypal - <a href="https://vovetosa.com/tisosorbide/">order imdur 20mg for sale</a> nimodipine pills
Ftfakz
lioresal for sale online - <a href="https://baclion.com/">purchase lioresal online cheap</a> piroxicam where to buy
Resloc
buy meloxicam 7.5mg generic - <a href="https://meloxiptan.com/asrizatriptan/">buy rizatriptan 10mg pills</a> ketorolac pill
Xssyha
buy periactin 4mg without prescription - <a href="https://periheptadn.com/">periactin 4mg for sale</a> buy generic tizanidine
Bkrwhi
buy trihexyphenidyl generic - <a href="https://voltapll.com.com/">buy generic artane</a> order diclofenac gel cheap
Bffqqh
how to get omnicef without a prescription - <a href="https://omnixcin.com/aminocycline/"></a> generic clindamycin
Dmcxys
buy generic isotretinoin 10mg - <a href="https://aisotane.com/">accutane cost</a> buy generic deltasone 5mg
Revqvm
order prednisone 10mg online - <a href="https://apreplson.com/">prednisone 10mg generic</a> elimite order online
Wxaiaz
acticin where to buy - <a href="https://actizacs.com/">order permethrin cream</a> retin gel cost
Dvzhng
betnovate 20gm without prescription - <a href="https://betnoson.com/benoquincre/">buy benoquin paypal</a> monobenzone oral
Tsnjfv
flagyl online order - <a href="https://cenforcevs.com/">cheap cenforce</a> cost cenforce 100mg
Ejwmta
augmentin 1000mg us - <a href="https://baugipro.com/">augmentin buy online</a> buy synthroid tablets
Pgvtrm
clindamycin us - <a href="https://clinycinpl.com/">cleocin over the counter</a> indocin 75mg ca
Gwjrka
order losartan generic - <a href="https://acephacrsa.com/">keflex pill</a> keflex 125mg canada
Iwvumv
crotamiton cream - <a href="https://aeuracream.com/caczone/">aczone drug</a> aczone for sale online
Yfnqja
buy modafinil 100mg pill - <a href="https://sleepagil.com/phenergan/">buy generic promethazine 25mg</a> order melatonin 3 mg generic
Yknwhm
bupropion 150mg price - <a href="https://bupropsl.com/ayurslim/">order ayurslim for sale</a> shuddha guggulu price
Pdippb
xeloda us - <a href="https://xelocap.com/mefenamicacid/">order mefenamic acid pill</a> danazol 100mg generic
Rqzfzf
progesterone online - <a href="https://apromid.com/gynelotrimin/">order ponstel vaginal cream</a> buy fertomid without a prescription
Mofdkd
purchase fosamax for sale - <a href="https://pilaxmax.com/tamoxifen/">buy tamoxifen 20mg online cheap</a> order provera 5mg pill
Pkydoa
buy aygestin 5 mg without prescription - <a href="https://norethgep.com/bimatoprost/">careprost without prescription</a> yasmin pills
Vuaxzh
purchase cabergoline pills - <a href="https://adostilin.com/">dostinex 0.25mg generic</a> alesse drug
Acvndk
yasmin oral - <a href="https://festrolp.com/ginette-35/">buy ginette 35 online cheap</a> anastrozole 1 mg cost
Pnujvu
г‚·гѓ«гѓ‡гѓЉгѓ•г‚Јгѓ« жµ·е¤–йЂљиІ© - <a href="https://jpedpharm.com/">г‚·гѓ«гѓ‡гѓЉгѓ•г‚Јгѓ« йЈІгЃїж–№</a> г‚їгѓЂгѓ©гѓ•г‚Јгѓ« гЃЇйЂљиІ©гЃ§гЃ®иіј
Wfmvgz
プレドニン おすすめ - <a href="https://jpaonlinep.com/">プレドニン通販 安全</a> アジスロマイシンの飲み方と効果
Fkzunl
プレドニン 薬局で買える - <a href="https://jpanfarap.com/jpaaccutane/">イソトレチノイン 飲み方</a> イソトレチノインの飲み方と効果
Skvmcc
eriacta work - <a href="https://eriagra.com/dapcalisb/">apcalis john</a> forzest bridge
Cnuciq
order indinavir without prescription - <a href="https://confindin.com/confido/">order generic confido</a> how to order voltaren gel
Txmcya
valif pills real - <a href="https://avaltiva.com/">valif pills cliff</a> cost sinemet 20mg
Gwkmid
modafinil cheap - <a href="https://provicef.com/cefadroxil/">buy duricef 250mg sale</a> combivir canada
Vcwrjj
ivermectin 3 mg for people - <a href="https://ivercand.com/">ivermectin 6mg pills for humans</a> carbamazepine for sale
Wrwlzw
promethazine online - <a href="https://prometacin.com/asciprofloxacin/">order ciprofloxacin 500 mg pill</a> lincomycin generic