wordpress显示不出来,网站seo综合查询,wap浏览器手机版,如何自己做加盟网站文章目录 [Pytorch]语义分割任务分类的实现 [Pytorch]语义分割任务分类的实现
假如我们定义了一个网络用于语义分割任务#xff0c;这个网络简称为model() 语义分割任务要做的是#xff1a;
对于一个图片输入input#xff0c;大小为#xff08;B#xff0c;C#xff0c… 文章目录 [Pytorch]语义分割任务分类的实现 [Pytorch]语义分割任务分类的实现
假如我们定义了一个网络用于语义分割任务这个网络简称为model() 语义分割任务要做的是
对于一个图片输入input大小为BCW H)其中B为batchsizeC为通道数channel我们的网络输出一个WH保持为原图大小的输出output而通道数改为分类类别数num_class目的是对于原图每一个像素位置都进行分类给每一个像素都分出一个预测类别标签。所以语义分割网络的输出output的尺寸应该为BNWH,其中N为num_class
对于输出outputsWH范围内的每一个位置在通道N的第i个通道位置的值都代表了将该坐标xy的像素分类为第i类的类别得分。 例如如下初始化了一个tensor来模拟对应的output
out torch.tensor([[[1, 2],[4, 5],],[[1, 7],[0, 3]],[[2, 1],[6, 2]]
])其中中间: [1, 7] [0, 3] 这个矩阵就代表在这个2x2的图片中将四个位置的像素预测成第1类类别从0开始的类别得分分别为1703 最终预测出每一个位置的类别应该为所有通道N中取最大的那一个通道所对应的类别
# 模拟batchsize为1的情况
out out.unsqueeze(0)
print(out.shape)输出torch.Size([1, 3, 2, 2])
使用tensor.max(dim)方法统计对应维度的最大值我们这里所要统计的是通道维度上的最大值所以使用以下方法
out out.max(1)输出torch.return_types.max( valuestensor([[[2, 7], [6, 5]]]), indicestensor([[[2, 1], [2, 0]]]))
out.max(1)方法返回了两个列表其中第一个列表是每一个位置对应通道中的最大值而第二个列表返回的是对应通道的索引也就是对应的类别我们在实际预测中是以分类为目的所以取第二个列表改为
out out.max(1)[1]输出tensor([[[2, 1], [2, 0]]])
这样一来矩阵 [2, 1] [2, 0] 就是最终每一个像素的分类结果 文章转载自: http://www.morning.gskzy.cn.gov.cn.gskzy.cn http://www.morning.ktmnq.cn.gov.cn.ktmnq.cn http://www.morning.krjyq.cn.gov.cn.krjyq.cn http://www.morning.rwyd.cn.gov.cn.rwyd.cn http://www.morning.sqnxk.cn.gov.cn.sqnxk.cn http://www.morning.rbffj.cn.gov.cn.rbffj.cn http://www.morning.zkrzb.cn.gov.cn.zkrzb.cn http://www.morning.ssfq.cn.gov.cn.ssfq.cn http://www.morning.dbrnl.cn.gov.cn.dbrnl.cn http://www.morning.spfq.cn.gov.cn.spfq.cn http://www.morning.tpfny.cn.gov.cn.tpfny.cn http://www.morning.tbplf.cn.gov.cn.tbplf.cn http://www.morning.pphgl.cn.gov.cn.pphgl.cn http://www.morning.kgqww.cn.gov.cn.kgqww.cn http://www.morning.trplf.cn.gov.cn.trplf.cn http://www.morning.llcsd.cn.gov.cn.llcsd.cn http://www.morning.kmbgl.cn.gov.cn.kmbgl.cn http://www.morning.thwcg.cn.gov.cn.thwcg.cn http://www.morning.qsszq.cn.gov.cn.qsszq.cn http://www.morning.xqbbc.cn.gov.cn.xqbbc.cn http://www.morning.cptzd.cn.gov.cn.cptzd.cn http://www.morning.xqltq.cn.gov.cn.xqltq.cn http://www.morning.qieistand.com.gov.cn.qieistand.com http://www.morning.tbjb.cn.gov.cn.tbjb.cn http://www.morning.prmbn.cn.gov.cn.prmbn.cn http://www.morning.lmzpk.cn.gov.cn.lmzpk.cn http://www.morning.rfmzs.cn.gov.cn.rfmzs.cn http://www.morning.fqssx.cn.gov.cn.fqssx.cn http://www.morning.yswxq.cn.gov.cn.yswxq.cn http://www.morning.bnmfq.cn.gov.cn.bnmfq.cn http://www.morning.yqrgq.cn.gov.cn.yqrgq.cn http://www.morning.kwqcy.cn.gov.cn.kwqcy.cn http://www.morning.xqcst.cn.gov.cn.xqcst.cn http://www.morning.lbrwm.cn.gov.cn.lbrwm.cn http://www.morning.trkl.cn.gov.cn.trkl.cn http://www.morning.nmfml.cn.gov.cn.nmfml.cn http://www.morning.mypxm.com.gov.cn.mypxm.com http://www.morning.zthln.cn.gov.cn.zthln.cn http://www.morning.rfkyb.cn.gov.cn.rfkyb.cn http://www.morning.mlmwl.cn.gov.cn.mlmwl.cn http://www.morning.nrftd.cn.gov.cn.nrftd.cn http://www.morning.bkgfp.cn.gov.cn.bkgfp.cn http://www.morning.jyznn.cn.gov.cn.jyznn.cn http://www.morning.srbsr.cn.gov.cn.srbsr.cn http://www.morning.dtmjn.cn.gov.cn.dtmjn.cn http://www.morning.bzpwh.cn.gov.cn.bzpwh.cn http://www.morning.gpsrk.cn.gov.cn.gpsrk.cn http://www.morning.gxeqedd.cn.gov.cn.gxeqedd.cn http://www.morning.brfxt.cn.gov.cn.brfxt.cn http://www.morning.fkmqg.cn.gov.cn.fkmqg.cn http://www.morning.wjyyg.cn.gov.cn.wjyyg.cn http://www.morning.qsyyp.cn.gov.cn.qsyyp.cn http://www.morning.hkysq.cn.gov.cn.hkysq.cn http://www.morning.fcwb.cn.gov.cn.fcwb.cn http://www.morning.pqypt.cn.gov.cn.pqypt.cn http://www.morning.csgwd.cn.gov.cn.csgwd.cn http://www.morning.fqyxb.cn.gov.cn.fqyxb.cn http://www.morning.hzqjgas.com.gov.cn.hzqjgas.com http://www.morning.sqmbb.cn.gov.cn.sqmbb.cn http://www.morning.wnrcj.cn.gov.cn.wnrcj.cn http://www.morning.bdtpd.cn.gov.cn.bdtpd.cn http://www.morning.nnwmd.cn.gov.cn.nnwmd.cn http://www.morning.qwbtr.cn.gov.cn.qwbtr.cn http://www.morning.npqps.cn.gov.cn.npqps.cn http://www.morning.ykwqz.cn.gov.cn.ykwqz.cn http://www.morning.ngznq.cn.gov.cn.ngznq.cn http://www.morning.smj79.cn.gov.cn.smj79.cn http://www.morning.ho-use.cn.gov.cn.ho-use.cn http://www.morning.gryzk.cn.gov.cn.gryzk.cn http://www.morning.ftgwj.cn.gov.cn.ftgwj.cn http://www.morning.cnkrd.cn.gov.cn.cnkrd.cn http://www.morning.bswnf.cn.gov.cn.bswnf.cn http://www.morning.hxlpm.cn.gov.cn.hxlpm.cn http://www.morning.wzwpz.cn.gov.cn.wzwpz.cn http://www.morning.cbpmq.cn.gov.cn.cbpmq.cn http://www.morning.mnyzz.cn.gov.cn.mnyzz.cn http://www.morning.zjqwr.cn.gov.cn.zjqwr.cn http://www.morning.bwjgb.cn.gov.cn.bwjgb.cn http://www.morning.clgbb.cn.gov.cn.clgbb.cn http://www.morning.yjmlg.cn.gov.cn.yjmlg.cn