Skip to content

Commit

Permalink
reverse paddle.vision.xxx import (#34489)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiboniu authored Jul 30, 2021
1 parent cc4bbfc commit e04b66f
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 44 deletions.
1 change: 0 additions & 1 deletion python/paddle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@
'logical_xor',
'exp',
'bernoulli',
'summary',
'sinh',
'round',
'DataParallel',
Expand Down
99 changes: 56 additions & 43 deletions python/paddle/vision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,63 @@
from .image import set_image_backend # noqa: F401
from .image import get_image_backend # noqa: F401
from .image import image_load # noqa: F401
from .models import LeNet as models_LeNet
import paddle.utils.deprecated as deprecated
from .datasets import DatasetFolder # noqa: F401
from .datasets import ImageFolder # noqa: F401
from .datasets import MNIST # noqa: F401
from .datasets import FashionMNIST # noqa: F401
from .datasets import Flowers # noqa: F401
from .datasets import Cifar10 # noqa: F401
from .datasets import Cifar100 # noqa: F401
from .datasets import VOC2012 # noqa: F401
from .models import ResNet # noqa: F401
from .models import resnet18 # noqa: F401
from .models import resnet34 # noqa: F401
from .models import resnet50 # noqa: F401
from .models import resnet101 # noqa: F401
from .models import resnet152 # noqa: F401
from .models import MobileNetV1 # noqa: F401
from .models import mobilenet_v1 # noqa: F401
from .models import MobileNetV2 # noqa: F401
from .models import mobilenet_v2 # noqa: F401
from .models import VGG # noqa: F401
from .models import vgg11 # noqa: F401
from .models import vgg13 # noqa: F401
from .models import vgg16 # noqa: F401
from .models import vgg19 # noqa: F401
from .models import LeNet # noqa: F401
from .transforms import BaseTransform # noqa: F401
from .transforms import Compose # noqa: F401
from .transforms import Resize # noqa: F401
from .transforms import RandomResizedCrop # noqa: F401
from .transforms import CenterCrop # noqa: F401
from .transforms import RandomHorizontalFlip # noqa: F401
from .transforms import RandomVerticalFlip # noqa: F401
from .transforms import Transpose # noqa: F401
from .transforms import Normalize # noqa: F401
from .transforms import BrightnessTransform # noqa: F401
from .transforms import SaturationTransform # noqa: F401
from .transforms import ContrastTransform # noqa: F401
from .transforms import HueTransform # noqa: F401
from .transforms import ColorJitter # noqa: F401
from .transforms import RandomCrop # noqa: F401
from .transforms import Pad # noqa: F401
from .transforms import RandomRotation # noqa: F401
from .transforms import Grayscale # noqa: F401
from .transforms import ToTensor # noqa: F401
from .transforms import to_tensor # noqa: F401
from .transforms import hflip # noqa: F401
from .transforms import vflip # noqa: F401
from .transforms import resize # noqa: F401
from .transforms import pad # noqa: F401
from .transforms import rotate # noqa: F401
from .transforms import to_grayscale # noqa: F401
from .transforms import crop # noqa: F401
from .transforms import center_crop # noqa: F401
from .transforms import adjust_brightness # noqa: F401
from .transforms import adjust_contrast # noqa: F401
from .transforms import adjust_hue # noqa: F401
from .transforms import normalize # noqa: F401

__all__ = [ #noqa
'set_image_backend', 'get_image_backend', 'image_load'
]


class LeNet(models_LeNet):
"""LeNet model from
`"LeCun Y, Bottou L, Bengio Y, et al. Gradient-based learning applied to document recognition[J]. Proceedings of the IEEE, 1998, 86(11): 2278-2324.`_
Args:
num_classes (int): output dim of last fc layer. If num_classes <=0, last fc layer
will not be defined. Default: 10.
Examples:
.. code-block:: python
from paddle.vision.models import LeNet
model = LeNet()
"""

@deprecated(
since="2.0.0",
update_to="paddle.vision.models.LeNet",
level=1,
reason="Please use new API in models, paddle.vision.LeNet will be removed in future"
)
def __init__(self, num_classes=10):
super(LeNet, self).__init__(num_classes=10)
self.num_classes = num_classes
self.features = nn.Sequential(
nn.Conv2D(
1, 6, 3, stride=1, padding=1),
nn.ReLU(),
nn.MaxPool2D(2, 2),
nn.Conv2D(
6, 16, 5, stride=1, padding=0),
nn.ReLU(),
nn.MaxPool2D(2, 2))

if num_classes > 0:
self.fc = nn.Sequential(
nn.Linear(400, 120),
nn.Linear(120, 84), nn.Linear(84, num_classes))

1 comment on commit e04b66f

@paddle-bot-old
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congratulation! Your pull request passed all required CI. You could ask reviewer(s) to approve and merge. 🎉

Please sign in to comment.