Back to Annotated Deep Learning Paper Implementations

CIFAR10 මත රෙස්නෙට් පුහුණු

docs/si/resnet/experiment.html

latest3.3 KB
Original Source

homeresnet

View code on Github

#

CIFAR10 මත රෙස්නෙට් පුහුණු

12fromtypingimportList,Optional1314fromtorchimportnn1516fromlabmlimportexperiment17fromlabml.configsimportoption18fromlabml\_nn.experiments.cifar10importCIFAR10Configs19fromlabml\_nn.resnetimportResNetBase

#

වින්යාසකිරීම්

සියලුමදත්ත කට්ටල ආශ්රිත වින්යාසයන්, ප්රශස්තකරණය සහ පුහුණු ලූපයක් නිර්වචනය කරන අපි භාවිතා CIFAR10Configs කරමු.

22classConfigs(CIFAR10Configs):

#

එක්එක් ලක්ෂණය සිතියම ප්රමාණය සඳහා කුට්ටි දැමිමේ අංකය

31n\_blocks:List[int]=[3,3,3]

#

එක්එක් විශේෂාංග සිතියම් ප්රමාණය සඳහා නාලිකා ගණන

33n\_channels:List[int]=[16,32,64]

#

බාධකප්රමාණ

35bottlenecks:Optional[List[int]]=None

#

ආරම්භකසංවලිත ස්ථරයේ කර්නල් ප්රමාණය

37first\_kernel\_size:int=3

#

ආකෘතියසාදන්න

40@option(Configs.model)41def\_resnet(c:Configs):

#

රෙස්නෙට්

46base=ResNetBase(c.n\_blocks,c.n\_channels,c.bottlenecks,img\_channels=3,first\_kernel\_size=c.first\_kernel\_size)

#

වර්ගීකරණයසඳහා රේඛීය ස්ථරය

48classification=nn.Linear(c.n\_channels[-1],10)

#

ඒවාගොඩගසන්න

51model=nn.Sequential(base,classification)

#

උපාංගයවෙත ආකෘතිය ගෙනයන්න

53returnmodel.to(c.device)

#

56defmain():

#

අත්හදාබැලීම සාදන්න

58experiment.create(name='resnet',comment='cifar10')

#

වින්යාසයන්සාදන්න

60conf=Configs()

#

වින්යාසයන්පූරණය කරන්න

62experiment.configs(conf,{63'bottlenecks':[8,16,16],64'n\_blocks':[6,6,6],6566'optimizer.optimizer':'Adam',67'optimizer.learning\_rate':2.5e-4,6869'epochs':500,70'train\_batch\_size':256,7172'train\_dataset':'cifar10\_train\_augmented',73'valid\_dataset':'cifar10\_valid\_no\_augment',74})

#

ඉතිරිකිරීම/පැටවීම සඳහා ආකෘතිය සකසන්න

76experiment.add\_pytorch\_models({'model':conf.model})

#

අත්හදාබැලීම ආරම්භ කර පුහුණු ලූපය ක්රියාත්මක කරන්න

78withexperiment.start():79conf.run()

#

83if\_\_name\_\_=='\_\_main\_\_':84main()

Trending Research Paperslabml.ai