未验证 提交 c3852b08 编写于 作者: W Weilong Wu 提交者: GitHub

[Eager] Support test_label_smooth_functional switch to eager mode (#42366)

上级 08f07dcb
...@@ -19,8 +19,6 @@ import paddle.fluid.dygraph as dg ...@@ -19,8 +19,6 @@ import paddle.fluid.dygraph as dg
import paddle.nn.functional as F import paddle.nn.functional as F
import paddle.fluid.initializer as I import paddle.fluid.initializer as I
import unittest import unittest
from paddle.fluid.framework import _enable_legacy_dygraph
_enable_legacy_dygraph()
class LabelSmoothTestCase(unittest.TestCase): class LabelSmoothTestCase(unittest.TestCase):
......
...@@ -1633,14 +1633,14 @@ def label_smooth(label, prior_dist=None, epsilon=0.1, name=None): ...@@ -1633,14 +1633,14 @@ def label_smooth(label, prior_dist=None, epsilon=0.1, name=None):
#[[[0.03333334 0.93333334 0.03333334] #[[[0.03333334 0.93333334 0.03333334]
# [0.93333334 0.03333334 0.93333334]]] # [0.93333334 0.03333334 0.93333334]]]
""" """
if epsilon > 1. or epsilon < 0.:
raise ValueError("The value of epsilon must be between 0 and 1.")
if in_dygraph_mode(): if in_dygraph_mode():
return _C_ops.final_state_label_smooth(label, prior_dist, return _C_ops.final_state_label_smooth(label, prior_dist,
float(epsilon)) float(epsilon))
if epsilon > 1. or epsilon < 0.: elif paddle.in_dynamic_mode():
raise ValueError("The value of epsilon must be between 0 and 1.")
if paddle.in_dynamic_mode():
return _C_ops.label_smooth(label, prior_dist, 'epsilon', float(epsilon)) return _C_ops.label_smooth(label, prior_dist, 'epsilon', float(epsilon))
check_variable_and_dtype(label, 'label', ['float32', 'float64'], check_variable_and_dtype(label, 'label', ['float32', 'float64'],
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册