Skip to content
GitLab
菜单
项目
群组
代码片段
帮助
帮助
支持
社区论坛
快捷键
?
提交反馈
登录/注册
切换导航
菜单
打开侧边栏
KMSCAKKSCFKA AKFACAMADCAS
tensorflow-federated
提交
ed5c3a9a
提交
ed5c3a9a
编辑于
11月 25, 2020
作者:
Zheng Xu
提交者:
tensorflow-copybara
11月 25, 2020
浏览文件
Remove the final softmax layer from the CNN model in simple_fedavg.
PiperOrigin-RevId: 344259493
上级
8d3641ed
变更
1
Hide whitespace changes
Inline
Side-by-side
tensorflow_federated/python/examples/simple_fedavg/emnist_fedavg_main.py
浏览文件 @
ed5c3a9a
...
...
@@ -81,9 +81,6 @@ def get_emnist_dataset():
def
create_original_fedavg_cnn_model
(
only_digits
=
True
):
"""The CNN model used in https://arxiv.org/abs/1602.05629.
This function is duplicated from research/optimization/emnist/models.py to
make this example completely stand-alone.
Args:
only_digits: If True, uses a final layer with 10 outputs, for use with the
digits only EMNIST dataset. If False, uses 62 outputs for the larger
...
...
@@ -115,7 +112,6 @@ def create_original_fedavg_cnn_model(only_digits=True):
tf
.
keras
.
layers
.
Flatten
(),
tf
.
keras
.
layers
.
Dense
(
512
,
activation
=
tf
.
nn
.
relu
),
tf
.
keras
.
layers
.
Dense
(
10
if
only_digits
else
62
),
tf
.
keras
.
layers
.
Activation
(
tf
.
nn
.
softmax
),
])
return
model
...
...
@@ -138,7 +134,7 @@ def main(argv):
def
tff_model_fn
():
"""Constructs a fully initialized model for use in federated averaging."""
keras_model
=
create_original_fedavg_cnn_model
(
only_digits
=
True
)
loss
=
tf
.
keras
.
losses
.
SparseCategoricalCrossentropy
()
loss
=
tf
.
keras
.
losses
.
SparseCategoricalCrossentropy
(
from_logits
=
True
)
return
simple_fedavg_tf
.
KerasModelWrapper
(
keras_model
,
test_data
.
element_spec
,
loss
)
...
...
编辑
预览
Supports
Markdown
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录