栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

2021-10-15-torch.cat()

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

2021-10-15-torch.cat()

torch.cat()
import torch

b, c, w, h = 2, 3, 4, 4

x = torch.zeros(b, c, w, h)
print(x.shape) # torch.Size([2, 3, 4, 4])
mean=[0.485, 0.456, 0.406] #rgb
std =[0.229, 0.224, 0.225]

get_channel = x[:,[0]]
print(get_channel.shape) # torch.Size([2, 1, 4, 4])


y = torch.cat([
    (x[:,[0]]-mean[0])/std[0],
    (x[:,[1]]-mean[1])/std[1],
    (x[:,[2]]-mean[2])/std[2],
], 1) # cat第几维度,第几维度就会增加
print(y.shape) # torch.Size([2, 3, 4, 4]) 
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/326723.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号