未验证 提交 b9f1f434 编写于 作者: L LielinJiang 提交者: GitHub

Move temporal_shift to paddle.nn.functional (#29261)

* move temporal_shift to functional
上级 d68af02c
......@@ -13348,7 +13348,7 @@ def temporal_shift(x, seg_num, shift_ratio=0.25, name=None):
import paddle.nn.functional as F
input = paddle.randn([6, 4, 2, 2])
out = paddle.fluid.layers.temporal_shift(x=input, seg_num=2, shift_ratio=0.2)
out = F.temporal_shift(x=input, seg_num=2, shift_ratio=0.2)
"""
helper = LayerHelper("temporal_shift", **locals())
check_variable_and_dtype(x, 'x', ['float32', 'float64'], 'temporal_shift')
......
......@@ -84,6 +84,15 @@ class TestTemporalShiftAPI(unittest.TestCase):
out = paddle.fluid.layers.temporal_shift(
x=input, seg_num=2, shift_ratio=0.2)
out_from_function = paddle.nn.functional.temporal_shift(
x=input, seg_num=2, shift_ratio=0.2)
# dygraph
with paddle.fluid.dygraph.guard():
input = paddle.randn([6, 4, 2, 2])
out = paddle.nn.functional.temporal_shift(
x=input, seg_num=2, shift_ratio=0.2)
if __name__ == "__main__":
unittest.main()
......@@ -216,3 +216,4 @@ from .vision import pixel_shuffle #DEFINE_ALIAS
from .input import one_hot #DEFINE_ALIAS
from .input import embedding #DEFINE_ALIAS
from ...fluid.layers import gather_tree
from ...fluid.layers import temporal_shift
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册