未验证 提交 135bd582 编写于 作者: B Bai Yifan 提交者: GitHub

use 1.8paddle log_softmax (#350)

上级 7a529cf1
...@@ -18,7 +18,6 @@ from __future__ import print_function ...@@ -18,7 +18,6 @@ from __future__ import print_function
import copy import copy
import paddle.fluid as fluid import paddle.fluid as fluid
import paddle.nn.functional as F
class DML(fluid.dygraph.Layer): class DML(fluid.dygraph.Layer):
...@@ -70,7 +69,7 @@ class DML(fluid.dygraph.Layer): ...@@ -70,7 +69,7 @@ class DML(fluid.dygraph.Layer):
cur_kl_loss = 0 cur_kl_loss = 0
for j in range(self.model_num): for j in range(self.model_num):
if i != j: if i != j:
x = F.log_softmax(logits[i], axis=1) x = fluid.layers.log_softmax(logits[i], axis=1)
y = fluid.layers.softmax(logits[j], axis=1) y = fluid.layers.softmax(logits[j], axis=1)
cur_kl_loss += fluid.layers.kldiv_loss( cur_kl_loss += fluid.layers.kldiv_loss(
x, y, reduction='batchmean') x, y, reduction='batchmean')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册