Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7fbe3424
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2299
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
7fbe3424
编写于
8月 21, 2023
作者:
D
David Nicolas
提交者:
GitHub
8月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[xdoctest] No.161-162 update models docstring for doc xdoctest (#56422)
上级
f9445d89
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
223 addition
and
223 deletion
+223
-223
python/paddle/vision/models/resnet.py
python/paddle/vision/models/resnet.py
+145
-145
python/paddle/vision/models/shufflenetv2.py
python/paddle/vision/models/shufflenetv2.py
+78
-78
未找到文件。
python/paddle/vision/models/resnet.py
浏览文件 @
7fbe3424
...
...
@@ -210,27 +210,27 @@ class ResNet(nn.Layer):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import ResNet
from paddle.vision.models.resnet import BottleneckBlock, BasicBlock
>>>
import paddle
>>>
from paddle.vision.models import ResNet
>>>
from paddle.vision.models.resnet import BottleneckBlock, BasicBlock
# build ResNet with 18 layers
resnet18 = ResNet(BasicBlock, 18)
>>>
# build ResNet with 18 layers
>>>
resnet18 = ResNet(BasicBlock, 18)
# build ResNet with 50 layers
resnet50 = ResNet(BottleneckBlock, 50)
>>>
# build ResNet with 50 layers
>>>
resnet50 = ResNet(BottleneckBlock, 50)
# build Wide ResNet model
wide_resnet50_2 = ResNet(BottleneckBlock, 50, width=64*2)
>>>
# build Wide ResNet model
>>>
wide_resnet50_2 = ResNet(BottleneckBlock, 50, width=64*2)
# build ResNeXt model
resnext50_32x4d = ResNet(BottleneckBlock, 50, width=4, groups=32)
>>>
# build ResNeXt model
>>>
resnext50_32x4d = ResNet(BottleneckBlock, 50, width=4, groups=32)
x = paddle.rand([1, 3, 224, 224])
out = resnet18(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = resnet18(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
def
__init__
(
...
...
@@ -380,20 +380,20 @@ def resnet18(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnet18
>>>
import paddle
>>>
from paddle.vision.models import resnet18
# build model
model = resnet18()
>>>
# build model
>>>
model = resnet18()
# build model and load imagenet pretrained weight
# model = resnet18(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnet18(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_resnet
(
'resnet18'
,
BasicBlock
,
18
,
pretrained
,
**
kwargs
)
...
...
@@ -413,20 +413,20 @@ def resnet34(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnet34
>>>
import paddle
>>>
from paddle.vision.models import resnet34
# build model
model = resnet34()
>>>
# build model
>>>
model = resnet34()
# build model and load imagenet pretrained weight
# model = resnet34(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnet34(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_resnet
(
'resnet34'
,
BasicBlock
,
34
,
pretrained
,
**
kwargs
)
...
...
@@ -446,20 +446,20 @@ def resnet50(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnet50
>>>
import paddle
>>>
from paddle.vision.models import resnet50
# build model
model = resnet50()
>>>
# build model
>>>
model = resnet50()
# build model and load imagenet pretrained weight
# model = resnet50(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnet50(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_resnet
(
'resnet50'
,
BottleneckBlock
,
50
,
pretrained
,
**
kwargs
)
...
...
@@ -479,20 +479,20 @@ def resnet101(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnet101
>>>
import paddle
>>>
from paddle.vision.models import resnet101
# build model
model = resnet101()
>>>
# build model
>>>
model = resnet101()
# build model and load imagenet pretrained weight
# model = resnet101(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnet101(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_resnet
(
'resnet101'
,
BottleneckBlock
,
101
,
pretrained
,
**
kwargs
)
...
...
@@ -512,20 +512,20 @@ def resnet152(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnet152
>>>
import paddle
>>>
from paddle.vision.models import resnet152
# build model
model = resnet152()
>>>
# build model
>>>
model = resnet152()
# build model and load imagenet pretrained weight
# model = resnet152(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnet152(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_resnet
(
'resnet152'
,
BottleneckBlock
,
152
,
pretrained
,
**
kwargs
)
...
...
@@ -545,20 +545,20 @@ def resnext50_32x4d(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnext50_32x4d
>>>
import paddle
>>>
from paddle.vision.models import resnext50_32x4d
# build model
model = resnext50_32x4d()
>>>
# build model
>>>
model = resnext50_32x4d()
# build model and load imagenet pretrained weight
# model = resnext50_32x4d(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnext50_32x4d(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
kwargs
[
'groups'
]
=
32
kwargs
[
'width'
]
=
4
...
...
@@ -580,20 +580,20 @@ def resnext50_64x4d(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnext50_64x4d
>>>
import paddle
>>>
from paddle.vision.models import resnext50_64x4d
# build model
model = resnext50_64x4d()
>>>
# build model
>>>
model = resnext50_64x4d()
# build model and load imagenet pretrained weight
# model = resnext50_64x4d(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnext50_64x4d(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
kwargs
[
'groups'
]
=
64
kwargs
[
'width'
]
=
4
...
...
@@ -615,20 +615,20 @@ def resnext101_32x4d(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnext101_32x4d
>>>
import paddle
>>>
from paddle.vision.models import resnext101_32x4d
# build model
model = resnext101_32x4d()
>>>
# build model
>>>
model = resnext101_32x4d()
# build model and load imagenet pretrained weight
# model = resnext101_32x4d(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnext101_32x4d(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
kwargs
[
'groups'
]
=
32
kwargs
[
'width'
]
=
4
...
...
@@ -652,20 +652,20 @@ def resnext101_64x4d(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnext101_64x4d
>>>
import paddle
>>>
from paddle.vision.models import resnext101_64x4d
# build model
model = resnext101_64x4d()
>>>
# build model
>>>
model = resnext101_64x4d()
# build model and load imagenet pretrained weight
# model = resnext101_64x4d(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnext101_64x4d(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
kwargs
[
'groups'
]
=
64
kwargs
[
'width'
]
=
4
...
...
@@ -689,20 +689,20 @@ def resnext152_32x4d(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnext152_32x4d
>>>
import paddle
>>>
from paddle.vision.models import resnext152_32x4d
# build model
model = resnext152_32x4d()
>>>
# build model
>>>
model = resnext152_32x4d()
# build model and load imagenet pretrained weight
# model = resnext152_32x4d(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnext152_32x4d(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
kwargs
[
'groups'
]
=
32
kwargs
[
'width'
]
=
4
...
...
@@ -726,20 +726,20 @@ def resnext152_64x4d(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import resnext152_64x4d
>>>
import paddle
>>>
from paddle.vision.models import resnext152_64x4d
# build model
model = resnext152_64x4d()
>>>
# build model
>>>
model = resnext152_64x4d()
# build model and load imagenet pretrained weight
# model = resnext152_64x4d(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = resnext152_64x4d(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
kwargs
[
'groups'
]
=
64
kwargs
[
'width'
]
=
4
...
...
@@ -763,20 +763,20 @@ def wide_resnet50_2(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import wide_resnet50_2
>>>
import paddle
>>>
from paddle.vision.models import wide_resnet50_2
# build model
model = wide_resnet50_2()
>>>
# build model
>>>
model = wide_resnet50_2()
# build model and load imagenet pretrained weight
# model = wide_resnet50_2(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = wide_resnet50_2(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
kwargs
[
'width'
]
=
64
*
2
return
_resnet
(
'wide_resnet50_2'
,
BottleneckBlock
,
50
,
pretrained
,
**
kwargs
)
...
...
@@ -797,20 +797,20 @@ def wide_resnet101_2(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import wide_resnet101_2
>>>
import paddle
>>>
from paddle.vision.models import wide_resnet101_2
# build model
model = wide_resnet101_2()
>>>
# build model
>>>
model = wide_resnet101_2()
# build model and load imagenet pretrained weight
# model = wide_resnet101_2(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = wide_resnet101_2(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
kwargs
[
'width'
]
=
64
*
2
return
_resnet
(
...
...
python/paddle/vision/models/shufflenetv2.py
浏览文件 @
7fbe3424
...
...
@@ -209,14 +209,14 @@ class ShuffleNetV2(nn.Layer):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import ShuffleNetV2
shufflenet_v2_swish = ShuffleNetV2(scale=1.0, act="swish")
x = paddle.rand([1, 3, 224, 224])
out = shufflenet_v2_swish(x)
print(out.shape)
#
[1, 1000]
>>>
import paddle
>>>
from paddle.vision.models import ShuffleNetV2
>>>
shufflenet_v2_swish = ShuffleNetV2(scale=1.0, act="swish")
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = shufflenet_v2_swish(x)
>>>
print(out.shape)
[1, 1000]
"""
def
__init__
(
self
,
scale
=
1.0
,
act
=
"relu"
,
num_classes
=
1000
,
with_pool
=
True
):
...
...
@@ -345,20 +345,20 @@ def shufflenet_v2_x0_25(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import shufflenet_v2_x0_25
>>>
import paddle
>>>
from paddle.vision.models import shufflenet_v2_x0_25
# build model
model = shufflenet_v2_x0_25()
>>>
# build model
>>>
model = shufflenet_v2_x0_25()
# build model and load imagenet pretrained weight
# model = shufflenet_v2_x0_25(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = shufflenet_v2_x0_25(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_shufflenet_v2
(
"shufflenet_v2_x0_25"
,
scale
=
0.25
,
pretrained
=
pretrained
,
**
kwargs
...
...
@@ -380,20 +380,20 @@ def shufflenet_v2_x0_33(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import shufflenet_v2_x0_33
>>>
import paddle
>>>
from paddle.vision.models import shufflenet_v2_x0_33
# build model
model = shufflenet_v2_x0_33()
>>>
# build model
>>>
model = shufflenet_v2_x0_33()
# build model and load imagenet pretrained weight
# model = shufflenet_v2_x0_33(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = shufflenet_v2_x0_33(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_shufflenet_v2
(
"shufflenet_v2_x0_33"
,
scale
=
0.33
,
pretrained
=
pretrained
,
**
kwargs
...
...
@@ -415,20 +415,20 @@ def shufflenet_v2_x0_5(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import shufflenet_v2_x0_5
>>>
import paddle
>>>
from paddle.vision.models import shufflenet_v2_x0_5
# build model
model = shufflenet_v2_x0_5()
>>>
# build model
>>>
model = shufflenet_v2_x0_5()
# build model and load imagenet pretrained weight
# model = shufflenet_v2_x0_5(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = shufflenet_v2_x0_5(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_shufflenet_v2
(
"shufflenet_v2_x0_5"
,
scale
=
0.5
,
pretrained
=
pretrained
,
**
kwargs
...
...
@@ -450,20 +450,20 @@ def shufflenet_v2_x1_0(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import shufflenet_v2_x1_0
>>>
import paddle
>>>
from paddle.vision.models import shufflenet_v2_x1_0
# build model
model = shufflenet_v2_x1_0()
>>>
# build model
>>>
model = shufflenet_v2_x1_0()
# build model and load imagenet pretrained weight
# model = shufflenet_v2_x1_0(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = shufflenet_v2_x1_0(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_shufflenet_v2
(
"shufflenet_v2_x1_0"
,
scale
=
1.0
,
pretrained
=
pretrained
,
**
kwargs
...
...
@@ -485,20 +485,20 @@ def shufflenet_v2_x1_5(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import shufflenet_v2_x1_5
>>>
import paddle
>>>
from paddle.vision.models import shufflenet_v2_x1_5
# build model
model = shufflenet_v2_x1_5()
>>>
# build model
>>>
model = shufflenet_v2_x1_5()
# build model and load imagenet pretrained weight
# model = shufflenet_v2_x1_5(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = shufflenet_v2_x1_5(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_shufflenet_v2
(
"shufflenet_v2_x1_5"
,
scale
=
1.5
,
pretrained
=
pretrained
,
**
kwargs
...
...
@@ -520,20 +520,20 @@ def shufflenet_v2_x2_0(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import shufflenet_v2_x2_0
>>>
import paddle
>>>
from paddle.vision.models import shufflenet_v2_x2_0
# build model
model = shufflenet_v2_x2_0()
>>>
# build model
>>>
model = shufflenet_v2_x2_0()
# build model and load imagenet pretrained weight
# model = shufflenet_v2_x2_0(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = shufflenet_v2_x2_0(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_shufflenet_v2
(
"shufflenet_v2_x2_0"
,
scale
=
2.0
,
pretrained
=
pretrained
,
**
kwargs
...
...
@@ -555,20 +555,20 @@ def shufflenet_v2_swish(pretrained=False, **kwargs):
Examples:
.. code-block:: python
import paddle
from paddle.vision.models import shufflenet_v2_swish
>>>
import paddle
>>>
from paddle.vision.models import shufflenet_v2_swish
# build model
model = shufflenet_v2_swish()
>>>
# build model
>>>
model = shufflenet_v2_swish()
# build model and load imagenet pretrained weight
# model = shufflenet_v2_swish(pretrained=True)
>>>
# build model and load imagenet pretrained weight
>>>
# model = shufflenet_v2_swish(pretrained=True)
x = paddle.rand([1, 3, 224, 224])
out = model(x)
>>>
x = paddle.rand([1, 3, 224, 224])
>>>
out = model(x)
print(out.shape)
#
[1, 1000]
>>>
print(out.shape)
[1, 1000]
"""
return
_shufflenet_v2
(
"shufflenet_v2_swish"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录