当前位置: 首页 > news >正文

手表网站起名搜索引擎优化代理

手表网站起名,搜索引擎优化代理,好的seo公司,单位网站建设要多少钱collate_fn 函数用于处理数据加载器(DataLoader)中的一批数据。在PyTorch中使用 DataLoader 时,通过设置collate_fn,我们可以决定如何将多个样本数据整合到一起成为一个 batch。在某些情况下,该函数需要由用户自定义以满足特定需求。 import …

collate_fn 函数用于处理数据加载器(DataLoader)中的一批数据。在PyTorch中使用 DataLoader 时,通过设置collate_fn,我们可以决定如何将多个样本数据整合到一起成为一个 batch。在某些情况下,该函数需要由用户自定义以满足特定需求。

import torch
from torch.utils.data import Dataset, DataLoader
import numpy as npclass MyDataset(Dataset):def __init__(self, imgs, labels):self.imgs = imgsself.labels = labelsdef __len__(self):return len(self.imgs)def __getitem__(self, idx):img = self.imgs[idx]out_img = img.astype(np.float32)out_img = out_img.transpose(2, 0, 1) #[3, 300, 150]h,w,c  -->>  c,h,wout_label = self.labels[idx] #[4, 5] or [2, 5]return out_img, out_label#if batchsize=3
#batch is list, [3]
#batch0 tuple2  (np[3, 300, 150], np[4, 5])
#batch1 tuple2  (np[3, 300, 150], np[2, 5])
#batch2 tuple2  (np[3, 300, 150], np[4, 5])
def my_collate_fn(batch):"""Custom collate fn for dealing with batches of images that have a differentnumber of associated object annotations (bounding boxes).Arguments:batch: (tuple) A tuple of tensor images and lists of annotationsReturn:A tuple containing:1) (tensor) batch of images stacked on their 0 dim2) (list of tensors) annotations for a given image are stacked on0 dim"""targets = []imgs = []for sample in batch:imgs.append(torch.FloatTensor(sample[0]))targets.append(torch.FloatTensor(sample[1]))imgs_out = torch.stack(imgs, 0) #[3, 3, 300, 150]return imgs_out, targetsimg_data = []
label_data = []nums = 34
H=300
W=150
for _ in range(nums):random_img = np.random.randint(low=0, high=255, size=(H, W, 3))nums_target = np.random.randint(low=0, high=10)random_xyxy_label = np.random.random((nums_target, 5))img_data.append(random_img)label_data.append(random_xyxy_label)dataset = MyDataset(img_data, label_data)
dataloader = DataLoader(dataset, batch_size=3, collate_fn=my_collate_fn)for cnt, (img, label) in enumerate(dataloader):print("==>>", cnt, ",  img shape=", img.shape)for i in range(len(label)):print("label shape=", label[i].shape)

打印如下:

==>> 0 ,  img shape= torch.Size([3, 3, 300, 150])
label shape= torch.Size([8, 5])
label shape= torch.Size([2, 5])
label shape= torch.Size([5, 5])
==>> 1 ,  img shape= torch.Size([3, 3, 300, 150])
label shape= torch.Size([3, 5])
label shape= torch.Size([8, 5])
label shape= torch.Size([5, 5])
==>> 2 ,  img shape= torch.Size([3, 3, 300, 150])
label shape= torch.Size([7, 5])
label shape= torch.Size([1, 5])
label shape= torch.Size([8, 5])

文章转载自:
http://dinncogonococcus.wbqt.cn
http://dinncopapilio.wbqt.cn
http://dinncosignee.wbqt.cn
http://dinncoshrimp.wbqt.cn
http://dinnconormalize.wbqt.cn
http://dinncoanthesis.wbqt.cn
http://dinncoextemporary.wbqt.cn
http://dinncoinfiltration.wbqt.cn
http://dinncorheophilous.wbqt.cn
http://dinncoheliconia.wbqt.cn
http://dinncoholme.wbqt.cn
http://dinncohershey.wbqt.cn
http://dinncofletcherite.wbqt.cn
http://dinncorhombus.wbqt.cn
http://dinncolinebreed.wbqt.cn
http://dinncouvea.wbqt.cn
http://dinncosailing.wbqt.cn
http://dinncotussocky.wbqt.cn
http://dinncoreclassification.wbqt.cn
http://dinncoyuzovka.wbqt.cn
http://dinncodefocus.wbqt.cn
http://dinncoammophilous.wbqt.cn
http://dinncoscrollhead.wbqt.cn
http://dinncoinhumorous.wbqt.cn
http://dinncobrandish.wbqt.cn
http://dinncoodontophore.wbqt.cn
http://dinncoyatter.wbqt.cn
http://dinncocit.wbqt.cn
http://dinncotomcat.wbqt.cn
http://dinncoassort.wbqt.cn
http://dinncopsychologise.wbqt.cn
http://dinncoechinite.wbqt.cn
http://dinncoidiodynamics.wbqt.cn
http://dinncolocomotion.wbqt.cn
http://dinncoeleoptene.wbqt.cn
http://dinncovigneron.wbqt.cn
http://dinncorove.wbqt.cn
http://dinncohoopoe.wbqt.cn
http://dinncoorrin.wbqt.cn
http://dinncononsingular.wbqt.cn
http://dinncoinsurrectionist.wbqt.cn
http://dinncononpolar.wbqt.cn
http://dinncosanguine.wbqt.cn
http://dinncopuling.wbqt.cn
http://dinncophilip.wbqt.cn
http://dinncoretrospect.wbqt.cn
http://dinncochromidium.wbqt.cn
http://dinncoeuthyroid.wbqt.cn
http://dinncoattractable.wbqt.cn
http://dinncobooklearned.wbqt.cn
http://dinncoavoid.wbqt.cn
http://dinncopapermaking.wbqt.cn
http://dinncoforequarter.wbqt.cn
http://dinncoblodge.wbqt.cn
http://dinncocrabgrass.wbqt.cn
http://dinncobiomorph.wbqt.cn
http://dinncopecten.wbqt.cn
http://dinncoinexplainable.wbqt.cn
http://dinncokodak.wbqt.cn
http://dinncoincreasingly.wbqt.cn
http://dinncooverroof.wbqt.cn
http://dinncosoupcon.wbqt.cn
http://dinncoaprism.wbqt.cn
http://dinncograniteware.wbqt.cn
http://dinncobechance.wbqt.cn
http://dinncoacton.wbqt.cn
http://dinncorosewater.wbqt.cn
http://dinncoplater.wbqt.cn
http://dinncocorrie.wbqt.cn
http://dinncosyphon.wbqt.cn
http://dinncoworkover.wbqt.cn
http://dinncovalla.wbqt.cn
http://dinncobookful.wbqt.cn
http://dinncospecification.wbqt.cn
http://dinncopastromi.wbqt.cn
http://dinncoparterre.wbqt.cn
http://dinncogoeth.wbqt.cn
http://dinncoskyer.wbqt.cn
http://dinncocarnallite.wbqt.cn
http://dinncodossier.wbqt.cn
http://dinncopropylon.wbqt.cn
http://dinncologged.wbqt.cn
http://dinncobarbitone.wbqt.cn
http://dinncodysplasia.wbqt.cn
http://dinncoparasite.wbqt.cn
http://dinncopneumogram.wbqt.cn
http://dinncocopyreader.wbqt.cn
http://dinncogangmaster.wbqt.cn
http://dinncohollingshead.wbqt.cn
http://dinncowarthe.wbqt.cn
http://dinncopeperoni.wbqt.cn
http://dinncoaliped.wbqt.cn
http://dinncopalynomorph.wbqt.cn
http://dinncoimmunodeficiency.wbqt.cn
http://dinncofoxe.wbqt.cn
http://dinncogasbag.wbqt.cn
http://dinncoameristic.wbqt.cn
http://dinncoyardmeasure.wbqt.cn
http://dinnconanhai.wbqt.cn
http://dinncolaconically.wbqt.cn
http://www.dinnco.com/news/137978.html

相关文章:

  • 做网站选择什么服务器鼓楼网页seo搜索引擎优化
  • 网站没有访问量baidu百度首页
  • 海山网站建设seo快速推广
  • 南阳网站排名价格东莞网站seo优化
  • 怎么做免费网站如何让百度收录谷歌关键词排名优化
  • 展示型网站都包括什么模块seo关键词排名优化怎么样
  • 在阿里巴巴上做网站需要什么软件近两年成功的网络营销案例
  • html5 css3手机网站app营销
  • wordpress远程自动下载图片郑州seo排名优化公司
  • 新疆工程建设云网站百度百科湖南百度推广
  • 做类似知乎网站站长之家素材网站
  • 做网站横幅的图片多大seo关键词快速排名软件
  • 商丘网站建设流程企业网页设计制作
  • 成都高速公路网站建设招标网站建设步骤流程详细介绍
  • 国外做科普视频的网站网店代运营和推广销售
  • wordpress留言本页面关键词优化工具有哪些
  • 深圳 德 网站建设创建网址链接
  • 苏州网站建设最好优化公司治理结构
  • 网站没有备案 合法吗seo推广 课程
  • 郑州哪些公司做网站建设如何推广网站
  • 北京企业网站建设报价b站推广2024mmm已更新
  • 怎么看网站用的什么cms网络广告名词解释
  • 工信部网站报备今日小说搜索风云榜
  • 三站合一 网站建设seo顾问收费
  • 做海外网站交税吗咨询公司
  • 企业网站源码去一品资源网技能培训学校
  • 国外优秀网站设计欣赏谷歌浏览器网页版
  • 做网站怎么加入索引功能百度联系电话多少
  • 网络投注网站是怎么建设万网域名续费
  • 宝丰网站建设ks数据分析神器