从前有座山,叫巴里赫德,他一个当一座山,十分的爽。
哎,想不到吧。
这个山里面有树林,有庙,有这个山里灵活的狗。山上有棵树,这棵树不叫高树,因为这个梗太老了。这棵树的形状有些奇特,大概就长这个样子。
iport torch
fro torch iport nn
iport torchnnfunctional as f
iport os
iport tenrboardx
fro torchutilsdata iport dataset
fro torchutilsdata iport dataloader
device torchdevicecuda if torchcudaisavaible else cpu
css vggbasesiples2nnodule:
def itself:
supervggbasesiples2, selfit
selfnv1 nnseential
nnnv2d1, 12, kernelsize3, stride1, paddg1,
nnbatchnor2d16,
nnre
66
selfaxpoolg1 nnaxpool2dkernelsize2, stride1
55
selfnv21 nnseential
nnnv2d12, 24, kernelsize3, stride1, paddg1,
nnre
selfaxpoolg21 nnaxpool2dkernelsize2, stride1
44
selfnv22 nnseential
nnnv2d24, 24, kernelsize3, stride1, paddg1,
nnre
selfaxpoolg2 nnaxpool2dkernelsize2, stride2
22
22
selffc nnlear2422, 2
def forardself, x:
batchsize ize0
out selfnv1x
out selfaxpoolg1out
out selfnv21out
out selfnv22out
out selfaxpoolg2out
out outviebatchsize, -1
out selffut
out flogftaxout, di1
return out
css tragdatasetdataset:
def itself:
supertragdataset, selfit
selfdatadictx xtra
selfdatadicty ytra
def titeself, dex:
t selfdatadictxdex, 0:36
t torchtenrtvie6, 6
return t, selfdatadictydex
def lenself:
return lenselfdatadicty
css testdatasetdataset:
def itself:
supertestdataset, selfit
selfdatadictx xvalidate
selfdatadicty yvalidate
def titeself, dex:
t selfdatadictxdex, 0:36
t torchtenrtvie6, 6
return t, selfdatadictydex
def lenself:
return lenselfdatadicty
def ncssification:
batchsize 256
tradataloader dataloadertragdataset, batchsizebatchsize, shufflefalse
testdataloader dataloadertestdataset, batchsizebatchsize, shufflefalse
epochnu 200
lr 0001
lr 0001
vggbasesiples2todevice
prt
loss
lossfunc nncrossentropyloss
optiizer
optiizer torchoptiadaparaeters, lrlr
optiizer torchoptisgdparaeters, lr
『加入书签,方便阅读』
-->> 本章未完,点击下一页继续阅读(第1页/共3页)