From 532e4bbf2a62e98fadce4eda6b9f07f235b40399 Mon Sep 17 00:00:00 2001 From: LielinJiang <50691816+LielinJiang@users.noreply.github.com> Date: Wed, 18 Nov 2020 15:04:14 +0800 Subject: [PATCH] fix docs (#28683) --- python/paddle/nn/functional/conv.py | 3 +-- python/paddle/nn/functional/loss.py | 2 -- python/paddle/nn/layer/loss.py | 2 -- python/paddle/utils/download.py | 2 +- python/paddle/vision/datasets/folder.py | 2 +- python/paddle/vision/transforms/functional.py | 10 +++------- 6 files changed, 6 insertions(+), 15 deletions(-) diff --git a/python/paddle/nn/functional/conv.py b/python/paddle/nn/functional/conv.py index 6df1ce368c1..1b0441b0a8c 100644 --- a/python/paddle/nn/functional/conv.py +++ b/python/paddle/nn/functional/conv.py @@ -211,7 +211,7 @@ def conv1d(x, [[0, 3, 4], [2, 9, 7], [5, 6, 8]]]).astype(np.float32) - paddle.disable_static() + x_var = paddle.to_tensor(x) w_var = paddle.to_tensor(w) y_var = F.conv1d(x_var, w_var) @@ -673,7 +673,6 @@ def conv1d_transpose(x, import paddle.nn.functional as F import numpy as np - paddle.disable_static() # shape: (1, 2, 4) x=np.array([[[4, 0, 9, 7], [8, 0, 9, 2,]]]).astype(np.float32) diff --git a/python/paddle/nn/functional/loss.py b/python/paddle/nn/functional/loss.py index ae04cdcc931..fa0789b7620 100644 --- a/python/paddle/nn/functional/loss.py +++ b/python/paddle/nn/functional/loss.py @@ -895,8 +895,6 @@ def kl_div(input, label, reduction='mean', name=None): import numpy as np import paddle.nn.functional as F - paddle.disable_static() - shape = (5, 20) input = np.random.uniform(-10, 10, shape).astype('float32') target = np.random.uniform(-10, 10, shape).astype('float32') diff --git a/python/paddle/nn/layer/loss.py b/python/paddle/nn/layer/loss.py index fdeed0ae49d..b16dcae7b63 100644 --- a/python/paddle/nn/layer/loss.py +++ b/python/paddle/nn/layer/loss.py @@ -773,8 +773,6 @@ class KLDivLoss(fluid.dygraph.Layer): import numpy as np import paddle.nn as nn - paddle.disable_static() - shape = (5, 20) x = np.random.uniform(-10, 10, shape).astype('float32') target = np.random.uniform(-10, 10, shape).astype('float32') diff --git a/python/paddle/utils/download.py b/python/paddle/utils/download.py index d8c0a2fc8c2..7ba20857435 100644 --- a/python/paddle/utils/download.py +++ b/python/paddle/utils/download.py @@ -123,7 +123,7 @@ def get_weights_path_from_url(url, md5sum=None): Examples: .. code-block:: python - from paddle.incubate.hapi.download import get_weights_path_from_url + from paddle.utils.download import get_weights_path_from_url resnet18_pretrained_weight_url = 'https://paddle-hapi.bj.bcebos.com/models/resnet18.pdparams' local_weight_path = get_weights_path_from_url(resnet18_pretrained_weight_url) diff --git a/python/paddle/vision/datasets/folder.py b/python/paddle/vision/datasets/folder.py index d005bc4f19e..8b17da9c923 100644 --- a/python/paddle/vision/datasets/folder.py +++ b/python/paddle/vision/datasets/folder.py @@ -306,7 +306,7 @@ class ImageFolder(Dataset): index (int): Index Returns: - tuple: (sample, target) where target is class_index of the target class. + sample of specific index. """ path = self.samples[index] sample = self.loader(path) diff --git a/python/paddle/vision/transforms/functional.py b/python/paddle/vision/transforms/functional.py index 7391ae322e3..67dff85f570 100644 --- a/python/paddle/vision/transforms/functional.py +++ b/python/paddle/vision/transforms/functional.py @@ -39,7 +39,7 @@ from . import functional_tensor as F_t __all__ = [ 'to_tensor', 'hflip', 'vflip', 'resize', 'pad', 'rotate', 'to_grayscale', 'crop', 'center_crop', 'adjust_brightness', 'adjust_contrast', 'adjust_hue', - 'to_grayscale', 'normalize' + 'normalize' ] @@ -283,13 +283,11 @@ def center_crop(img, output_size): return F_cv2.center_crop(img, output_size) -def hflip(img, backend='pil'): +def hflip(img): """Horizontally flips the given Image or np.array. Args: img (PIL.Image|np.array): Image to be flipped. - backend (str, optional): The image proccess backend type. Options are `pil`, - `cv2`. Default: 'pil'. Returns: PIL.Image or np.array: Horizontall flipped image. @@ -576,8 +574,6 @@ def to_grayscale(img, num_output_channels=1): Args: img (PIL.Image|np.array): Image to be converted to grayscale. - backend (str, optional): The image proccess backend type. Options are `pil`, - `cv2`. Default: 'pil'. Returns: PIL.Image or np.array: Grayscale version of the image. @@ -624,7 +620,7 @@ def normalize(img, mean, std, data_format='CHW', to_rgb=False): this option will be igored. Default: False. Returns: - Tensor: Normalized mage. Data format is same as input img. + np.ndarray or Tensor: Normalized mage. Data format is same as input img. Examples: .. code-block:: python -- GitLab