Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
60fa3303
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
60fa3303
编写于
6月 17, 2020
作者:
Y
yao_yf
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modelzoo_widedeep_modify
上级
2e002ab6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
14 addition
and
13 deletion
+14
-13
model_zoo/wide_and_deep/src/config.py
model_zoo/wide_and_deep/src/config.py
+2
-2
model_zoo/wide_and_deep/src/wide_and_deep.py
model_zoo/wide_and_deep/src/wide_and_deep.py
+12
-11
未找到文件。
model_zoo/wide_and_deep/src/config.py
浏览文件 @
60fa3303
...
...
@@ -26,7 +26,7 @@ def argparse_init():
parser
.
add_argument
(
"--batch_size"
,
type
=
int
,
default
=
16000
)
parser
.
add_argument
(
"--eval_batch_size"
,
type
=
int
,
default
=
16000
)
parser
.
add_argument
(
"--field_size"
,
type
=
int
,
default
=
39
)
parser
.
add_argument
(
"--vocab_size"
,
type
=
int
,
default
=
184965
)
parser
.
add_argument
(
"--vocab_size"
,
type
=
int
,
default
=
200000
)
parser
.
add_argument
(
"--emb_dim"
,
type
=
int
,
default
=
80
)
parser
.
add_argument
(
"--deep_layer_dim"
,
type
=
int
,
nargs
=
'+'
,
default
=
[
1024
,
512
,
256
,
128
])
parser
.
add_argument
(
"--deep_layer_act"
,
type
=
str
,
default
=
'relu'
)
...
...
@@ -50,7 +50,7 @@ class WideDeepConfig():
self
.
batch_size
=
16000
self
.
eval_batch_size
=
16000
self
.
field_size
=
39
self
.
vocab_size
=
184965
self
.
vocab_size
=
200000
self
.
emb_dim
=
80
self
.
deep_layer_dim
=
[
1024
,
512
,
256
,
128
]
self
.
deep_layer_act
=
'relu'
...
...
model_zoo/wide_and_deep/src/wide_and_deep.py
浏览文件 @
60fa3303
...
...
@@ -82,7 +82,7 @@ class DenseLayer(nn.Cell):
"""
def
__init__
(
self
,
input_dim
,
output_dim
,
weight_bias_init
,
act_str
,
keep_prob
=
0.7
,
scale_coef
=
1.0
,
convert_dtype
=
True
,
drop_out
=
False
):
keep_prob
=
0.7
,
use_activation
=
True
,
convert_dtype
=
True
,
drop_out
=
False
):
super
(
DenseLayer
,
self
).
__init__
()
weight_init
,
bias_init
=
weight_bias_init
self
.
weight
=
init_method
(
...
...
@@ -93,9 +93,7 @@ class DenseLayer(nn.Cell):
self
.
bias_add
=
P
.
BiasAdd
()
self
.
cast
=
P
.
Cast
()
self
.
dropout
=
Dropout
(
keep_prob
=
keep_prob
)
self
.
mul
=
P
.
Mul
()
self
.
realDiv
=
P
.
RealDiv
()
self
.
scale_coef
=
scale_coef
self
.
use_activation
=
use_activation
self
.
convert_dtype
=
convert_dtype
self
.
drop_out
=
drop_out
...
...
@@ -110,20 +108,23 @@ class DenseLayer(nn.Cell):
return
act_func
def
construct
(
self
,
x
):
x
=
self
.
act_func
(
x
)
if
self
.
training
and
self
.
drop_out
:
x
=
self
.
dropout
(
x
)
x
=
self
.
mul
(
x
,
self
.
scale_coef
)
if
self
.
convert_dtype
:
x
=
self
.
cast
(
x
,
mstype
.
float16
)
weight
=
self
.
cast
(
self
.
weight
,
mstype
.
float16
)
bias
=
self
.
cast
(
self
.
bias
,
mstype
.
float16
)
wx
=
self
.
matmul
(
x
,
weight
)
wx
=
self
.
bias_add
(
wx
,
bias
)
if
self
.
use_activation
:
wx
=
self
.
act_func
(
wx
)
wx
=
self
.
cast
(
wx
,
mstype
.
float32
)
else
:
wx
=
self
.
matmul
(
x
,
self
.
weight
)
wx
=
self
.
realDiv
(
wx
,
self
.
scale_coef
)
output
=
self
.
bias_add
(
wx
,
self
.
bias
)
return
output
wx
=
self
.
bias_add
(
wx
,
self
.
bias
)
if
self
.
use_activation
:
wx
=
self
.
act_func
(
wx
)
return
wx
class
WideDeepModel
(
nn
.
Cell
):
...
...
@@ -185,7 +186,7 @@ class WideDeepModel(nn.Cell):
self
.
all_dim_list
[
5
],
self
.
weight_bias_init
,
self
.
deep_layer_act
,
convert_dtype
=
True
,
drop_out
=
config
.
dropout_flag
)
use_activation
=
False
,
convert_dtype
=
True
,
drop_out
=
config
.
dropout_flag
)
self
.
gather_v2
=
P
.
GatherV2
()
self
.
mul
=
P
.
Mul
()
...
...
@@ -270,7 +271,7 @@ class TrainStepWrap(nn.Cell):
sens (Number): The adjust parameter. Default: 1000.0
"""
def
__init__
(
self
,
network
,
sens
=
10
00
.0
):
def
__init__
(
self
,
network
,
sens
=
10
24
.0
):
super
(
TrainStepWrap
,
self
).
__init__
()
self
.
network
=
network
self
.
network
.
set_train
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录