1111:::::::::
1212 - **Block ** (BasicBlock|BottleneckBlock) - 模型的残差模块。
1313 - **depth ** (int,可选) - resnet模型的深度。默认值:50。
14- - **width ** (int,可选) - resnet模型的基础宽度。默认值:64。
14+ - **groups ** (int,可选) - 各个卷积块的分组数。默认值:1。
15+ - **width_per_group ** (int,可选) - 各个卷积块的每个卷积组基础宽度。默认值:64。
1516 - **num_classes ** (int, 可选) - 最后一个全连接层输出的维度。如果该值小于0,则不定义最后一个全连接层。默认值:1000。
1617 - **with_pool ** (bool,可选) - 是否定义最后一个全连接层之前的池化层。默认值:True。
1718
@@ -27,13 +28,20 @@ ResNet模型,Layer的实例。
2728 from paddle.vision.models import ResNet
2829 from paddle.vision.models.resnet import BottleneckBlock, BasicBlock
2930
31+ # build ResNet with 18 layers
32+ resnet18 = ResNet(BasicBlock, 18 )
33+
34+ # build ResNet with 50 layers
3035 resnet50 = ResNet(BottleneckBlock, 50 )
3136
32- wide_resnet50_2 = ResNet(BottleneckBlock, 50 , width = 64 * 2 )
37+ # build Wide ResNet model
38+ wide_resnet50_2 = ResNet(BottleneckBlock, 50 , width_per_group = 64 * 2 )
3339
34- resnet18 = ResNet(BasicBlock, 18 )
40+ # build ResNeXt model
41+ resnext50_32x4d = ResNet(BottleneckBlock, 50 , groups = 32 , width_per_group = 4 )
3542
3643 x = paddle.rand([1 , 3 , 224 , 224 ])
3744 out = resnet18(x)
3845
3946 print (out.shape)
47+ # [1, 1000]
0 commit comments