From 5d5faba8b1898b00f56469418e2313c8e8e435c4 Mon Sep 17 00:00:00 2001 From: xiaoting <31891223+tink2123@users.noreply.github.com> Date: Thu, 31 Dec 2020 13:18:16 +0800 Subject: [PATCH] [cherry-pick] add alias for upsample (#29984) * add alias for upsample, test=develop * add alias for upsample * fix example --- python/paddle/nn/__init__.py | 2 ++ python/paddle/nn/layer/common.py | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/python/paddle/nn/__init__.py b/python/paddle/nn/__init__.py index 12a5cdd0cc5..3a552d588be 100644 --- a/python/paddle/nn/__init__.py +++ b/python/paddle/nn/__init__.py @@ -76,6 +76,8 @@ from .layer.common import Embedding #DEFINE_ALIAS from .layer.common import Linear #DEFINE_ALIAS from .layer.common import Flatten #DEFINE_ALIAS from .layer.common import Upsample #DEFINE_ALIAS +from .layer.common import UpsamplingNearest2D #DEFINE_ALIAS +from .layer.common import UpsamplingBilinear2D #DEFINE_ALIAS from .layer.common import Bilinear #DEFINE_ALIAS from .layer.common import Dropout #DEFINE_ALIAS from .layer.common import Dropout2D #DEFINE_ALIAS diff --git a/python/paddle/nn/layer/common.py b/python/paddle/nn/layer/common.py index 389af0b1a87..5ae6e3ed770 100644 --- a/python/paddle/nn/layer/common.py +++ b/python/paddle/nn/layer/common.py @@ -421,7 +421,7 @@ class UpsamplingNearest2D(layers.Layer): import paddle import paddle.nn as nn - input_data = paddle.rand(2,3,6,10).astype("float32") + input_data = paddle.rand(shape=(2,3,6,10)).astype("float32") upsample_out = paddle.nn.UpsamplingNearest2D(size=[12,12]) input = paddle.to_tensor(input_data) output = upsample_out(x=input) @@ -498,7 +498,7 @@ class UpsamplingBilinear2D(layers.Layer): import paddle import paddle.nn as nn - input_data = paddle.rand(2,3,6,10).astype("float32") + input_data = paddle.rand(shape=(2,3,6,10)).astype("float32") upsample_out = paddle.nn.UpsamplingBilinear2D(size=[12,12]) input = paddle.to_tensor(input_data) output = upsample_out(x=input) -- GitLab