Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
bce9c8c4
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
bce9c8c4
编写于
4月 03, 2022
作者:
W
Weilong Wu
提交者:
GitHub
4月 03, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[Eager] Support two callback related tests (#41275)
上级
af247f95
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
3 deletion
+20
-3
python/paddle/tests/test_callback_reduce_lr_on_plateau.py
python/paddle/tests/test_callback_reduce_lr_on_plateau.py
+13
-2
python/paddle/tests/test_callback_visualdl.py
python/paddle/tests/test_callback_visualdl.py
+7
-1
未找到文件。
python/paddle/tests/test_callback_reduce_lr_on_plateau.py
浏览文件 @
bce9c8c4
...
...
@@ -29,6 +29,7 @@ from paddle.hapi.callbacks import config_callbacks
from
paddle.vision.datasets
import
MNIST
from
paddle.metric
import
Accuracy
from
paddle.nn.layer.loss
import
CrossEntropyLoss
from
paddle.fluid.framework
import
_test_eager_guard
,
_in_legacy_dygraph
# Accelerate unittest
...
...
@@ -38,7 +39,7 @@ class CustomMnist(MNIST):
class
TestReduceLROnPlateau
(
unittest
.
TestCase
):
def
test
_reduce_lr_on_plateau
(
self
):
def
func
_reduce_lr_on_plateau
(
self
):
transform
=
T
.
Compose
([
T
.
Transpose
(),
T
.
Normalize
([
127.5
],
[
127.5
])])
train_dataset
=
CustomMnist
(
mode
=
'train'
,
transform
=
transform
)
val_dataset
=
CustomMnist
(
mode
=
'test'
,
transform
=
transform
)
...
...
@@ -59,7 +60,12 @@ class TestReduceLROnPlateau(unittest.TestCase):
epochs
=
10
,
callbacks
=
[
callbacks
])
def
test_warn_or_error
(
self
):
def
test_reduce_lr_on_plateau
(
self
):
with
_test_eager_guard
():
self
.
func_reduce_lr_on_plateau
()
self
.
func_reduce_lr_on_plateau
()
def
func_warn_or_error
(
self
):
with
self
.
assertRaises
(
ValueError
):
paddle
.
callbacks
.
ReduceLROnPlateau
(
factor
=
2.0
)
# warning
...
...
@@ -101,6 +107,11 @@ class TestReduceLROnPlateau(unittest.TestCase):
epochs
=
3
,
callbacks
=
[
callbacks
])
def
test_warn_or_error
(
self
):
with
_test_eager_guard
():
self
.
func_warn_or_error
()
self
.
func_warn_or_error
()
if
__name__
==
'__main__'
:
unittest
.
main
()
python/paddle/tests/test_callback_visualdl.py
浏览文件 @
bce9c8c4
...
...
@@ -29,6 +29,7 @@ import paddle.vision.transforms as T
from
paddle.vision.datasets
import
MNIST
from
paddle.metric
import
Accuracy
from
paddle.nn.layer.loss
import
CrossEntropyLoss
from
paddle.fluid.framework
import
_test_eager_guard
,
_in_legacy_dygraph
class
MnistDataset
(
MNIST
):
...
...
@@ -43,7 +44,7 @@ class TestCallbacks(unittest.TestCase):
def
tearDown
(
self
):
shutil
.
rmtree
(
self
.
save_dir
)
def
test
_visualdl_callback
(
self
):
def
func
_visualdl_callback
(
self
):
# visualdl not support python2
if
sys
.
version_info
<
(
3
,
):
return
...
...
@@ -70,6 +71,11 @@ class TestCallbacks(unittest.TestCase):
batch_size
=
64
,
callbacks
=
callback
)
def
test_visualdl_callback
(
self
):
with
_test_eager_guard
():
self
.
func_visualdl_callback
()
self
.
func_visualdl_callback
()
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录