Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PaddlePaddle Hackathon] add ResNeXt #36070

Merged
merged 1 commit into from
Oct 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion python/paddle/tests/test_pretrained_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def infer(self, arch):

def test_models(self):
arches = [
'mobilenet_v1', 'mobilenet_v2', 'resnet18', 'vgg16', 'alexnet'
'mobilenet_v1', 'mobilenet_v2', 'resnet18', 'vgg16', 'alexnet',
'resnext50_32x4d'
]
for arch in arches:
self.infer(arch)
Expand Down
18 changes: 18 additions & 0 deletions python/paddle/tests/test_vision_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,24 @@ def test_resnet152(self):
def test_alexnet(self):
self.models_infer('alexnet')

def test_resnext50_32x4d(self):
self.models_infer('resnext50_32x4d')

def test_resnext50_64x4d(self):
self.models_infer('resnext50_64x4d')

def test_resnext101_32x4d(self):
self.models_infer('resnext101_32x4d')

def test_resnext101_64x4d(self):
self.models_infer('resnext101_64x4d')

def test_resnext152_32x4d(self):
self.models_infer('resnext152_32x4d')

def test_resnext152_64x4d(self):
self.models_infer('resnext152_64x4d')

def test_vgg16_num_classes(self):
vgg16 = models.__dict__['vgg16'](pretrained=False, num_classes=10)

Expand Down
7 changes: 7 additions & 0 deletions python/paddle/vision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
from .models import LeNet # noqa: F401
from .models import AlexNet # noqa: F401
from .models import alexnet # noqa: F401
from .models import ResNeXt # noqa: F401
from .models import resnext50_32x4d # noqa: F401
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api名称跟resnet50不一致的原因是什么?resnet50是否如何区分32和64的?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为 ResNeXt 在卷积时是分组进行的呀,ResNet 是没有分组的过程的,因此 ResNeXt 有一个分组数量的参数 cardinality,resnext50_32x4d 中的 32 是指 cardinality = 32

另外作为参考 torchvision.models 也是如此命名的

image

from .models import resnext50_64x4d # noqa: F401
from .models import resnext101_32x4d # noqa: F401
from .models import resnext101_64x4d # noqa: F401
from .models import resnext152_32x4d # noqa: F401
from .models import resnext152_64x4d # noqa: F401
from .transforms import BaseTransform # noqa: F401
from .transforms import Compose # noqa: F401
from .transforms import Resize # noqa: F401
Expand Down
16 changes: 15 additions & 1 deletion python/paddle/vision/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
from .lenet import LeNet # noqa: F401
from .alexnet import AlexNet # noqa: F401
from .alexnet import alexnet # noqa: F401
from .resnext import ResNeXt # noqa: F401
from .resnext import resnext50_32x4d # noqa: F401
from .resnext import resnext50_64x4d # noqa: F401
from .resnext import resnext101_32x4d # noqa: F401
from .resnext import resnext101_64x4d # noqa: F401
from .resnext import resnext152_32x4d # noqa: F401
from .resnext import resnext152_64x4d # noqa: F401

__all__ = [ #noqa
'ResNet',
Expand All @@ -49,5 +56,12 @@
'mobilenet_v2',
'LeNet',
'AlexNet',
'alexnet'
'alexnet',
'ResNeXt',
'resnext50_32x4d',
'resnext50_64x4d',
'resnext101_32x4d',
'resnext101_64x4d',
'resnext152_32x4d',
'resnext152_64x4d'
]
Loading