Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MindSpore
docs
提交
9f79db30
D
docs
项目概览
MindSpore
/
docs
通知
4
Star
2
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9f79db30
编写于
4月 02, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
4月 02, 2020
浏览文件
操作
浏览文件
下载
差异文件
!5 update lenet and alexnet
Merge pull request !5 from wukesong/update-lenet-alexnet
上级
33b2ba51
e3884091
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
4 addition
and
7 deletion
+4
-7
tutorials/source_zh_cn/quick_start/quick_start.md
tutorials/source_zh_cn/quick_start/quick_start.md
+2
-4
tutorials/tutorial_code/lenet.py
tutorials/tutorial_code/lenet.py
+2
-3
未找到文件。
tutorials/source_zh_cn/quick_start/quick_start.md
浏览文件 @
9f79db30
...
@@ -228,8 +228,6 @@ def fc_with_initialize(input_channels, out_channels):
...
@@ -228,8 +228,6 @@ def fc_with_initialize(input_channels, out_channels):
神经网络的各层需要预先在
`__init__()`
方法中定义,然后通过定义
`construct()`
方法来完成神经网络的前向构造。按照LeNet的网络结构,定义网络各层如下:
神经网络的各层需要预先在
`__init__()`
方法中定义,然后通过定义
`construct()`
方法来完成神经网络的前向构造。按照LeNet的网络结构,定义网络各层如下:
```
python
```
python
import
mindspore.ops.operations
as
P
class
LeNet5
(
nn
.
Cell
):
class
LeNet5
(
nn
.
Cell
):
"""
"""
Lenet network structure
Lenet network structure
...
@@ -245,7 +243,7 @@ class LeNet5(nn.Cell):
...
@@ -245,7 +243,7 @@ class LeNet5(nn.Cell):
self
.
fc3
=
fc_with_initialize
(
84
,
10
)
self
.
fc3
=
fc_with_initialize
(
84
,
10
)
self
.
relu
=
nn
.
ReLU
()
self
.
relu
=
nn
.
ReLU
()
self
.
max_pool2d
=
nn
.
MaxPool2d
(
kernel_size
=
2
,
stride
=
2
)
self
.
max_pool2d
=
nn
.
MaxPool2d
(
kernel_size
=
2
,
stride
=
2
)
self
.
reshape
=
P
.
Reshape
()
self
.
flatten
=
nn
.
Flatten
()
#use the preceding operators to construct networks
#use the preceding operators to construct networks
def
construct
(
self
,
x
):
def
construct
(
self
,
x
):
...
@@ -255,7 +253,7 @@ class LeNet5(nn.Cell):
...
@@ -255,7 +253,7 @@ class LeNet5(nn.Cell):
x
=
self
.
conv2
(
x
)
x
=
self
.
conv2
(
x
)
x
=
self
.
relu
(
x
)
x
=
self
.
relu
(
x
)
x
=
self
.
max_pool2d
(
x
)
x
=
self
.
max_pool2d
(
x
)
x
=
self
.
reshape
(
x
,
(
self
.
batch_size
,
-
1
)
)
x
=
self
.
flatten
(
x
)
x
=
self
.
fc1
(
x
)
x
=
self
.
fc1
(
x
)
x
=
self
.
relu
(
x
)
x
=
self
.
relu
(
x
)
x
=
self
.
fc2
(
x
)
x
=
self
.
fc2
(
x
)
...
...
tutorials/tutorial_code/lenet.py
浏览文件 @
9f79db30
...
@@ -24,7 +24,6 @@ from mindspore import context
...
@@ -24,7 +24,6 @@ from mindspore import context
from
mindspore.train.serialization
import
load_checkpoint
,
load_param_into_net
from
mindspore.train.serialization
import
load_checkpoint
,
load_param_into_net
from
mindspore.train.callback
import
ModelCheckpoint
,
CheckpointConfig
,
LossMonitor
from
mindspore.train.callback
import
ModelCheckpoint
,
CheckpointConfig
,
LossMonitor
from
mindspore.train
import
Model
from
mindspore.train
import
Model
import
mindspore.ops.operations
as
P
from
mindspore.common.initializer
import
TruncatedNormal
from
mindspore.common.initializer
import
TruncatedNormal
import
mindspore.dataset.transforms.vision.c_transforms
as
CV
import
mindspore.dataset.transforms.vision.c_transforms
as
CV
import
mindspore.dataset.transforms.c_transforms
as
C
import
mindspore.dataset.transforms.c_transforms
as
C
...
@@ -150,7 +149,7 @@ class LeNet5(nn.Cell):
...
@@ -150,7 +149,7 @@ class LeNet5(nn.Cell):
self
.
fc3
=
fc_with_initialize
(
84
,
10
)
self
.
fc3
=
fc_with_initialize
(
84
,
10
)
self
.
relu
=
nn
.
ReLU
()
self
.
relu
=
nn
.
ReLU
()
self
.
max_pool2d
=
nn
.
MaxPool2d
(
kernel_size
=
2
,
stride
=
2
)
self
.
max_pool2d
=
nn
.
MaxPool2d
(
kernel_size
=
2
,
stride
=
2
)
self
.
reshape
=
P
.
Reshape
()
self
.
flatten
=
nn
.
Flatten
()
# use the preceding operators to construct networks
# use the preceding operators to construct networks
def
construct
(
self
,
x
):
def
construct
(
self
,
x
):
...
@@ -160,7 +159,7 @@ class LeNet5(nn.Cell):
...
@@ -160,7 +159,7 @@ class LeNet5(nn.Cell):
x
=
self
.
conv2
(
x
)
x
=
self
.
conv2
(
x
)
x
=
self
.
relu
(
x
)
x
=
self
.
relu
(
x
)
x
=
self
.
max_pool2d
(
x
)
x
=
self
.
max_pool2d
(
x
)
x
=
self
.
reshape
(
x
,
(
self
.
batch_size
,
-
1
)
)
x
=
self
.
flatten
(
x
)
x
=
self
.
fc1
(
x
)
x
=
self
.
fc1
(
x
)
x
=
self
.
relu
(
x
)
x
=
self
.
relu
(
x
)
x
=
self
.
fc2
(
x
)
x
=
self
.
fc2
(
x
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录