diff --git a/mindspore/train/__init__.py b/mindspore/train/__init__.py index 6964612b7f2..c02107cd30d 100644 --- a/mindspore/train/__init__.py +++ b/mindspore/train/__init__.py @@ -20,5 +20,11 @@ Helper functions in train piplines. from .model import Model from .dataset_helper import DatasetHelper, connect_network_with_dataset from . import amp +from .amp import build_train_network +from .loss_scale_manager import LossScaleManager, FixedLossScaleManager, DynamicLossScaleManager +from .serialization import save_checkpoint, load_checkpoint, load_param_into_net, export, parse_print,\ + build_searched_strategy, merge_sliced_parameter -__all__ = ["Model", "DatasetHelper", "amp", "connect_network_with_dataset"] +__all__ = ["Model", "DatasetHelper", "amp", "connect_network_with_dataset", "build_train_network", "LossScaleManager", + "FixedLossScaleManager", "DynamicLossScaleManager", "save_checkpoint", "load_checkpoint", + "load_param_into_net", "export", "parse_print", "build_searched_strategy", "merge_sliced_parameter"] diff --git a/mindspore/train/amp.py b/mindspore/train/amp.py index 5042575dabe..b9004a79572 100644 --- a/mindspore/train/amp.py +++ b/mindspore/train/amp.py @@ -26,8 +26,6 @@ from .loss_scale_manager import DynamicLossScaleManager, LossScaleManager from ..context import ParallelMode from .. import context -__all__ = ["build_train_network"] - class OutputTo16(nn.Cell): "Wrap cell for amp. Cast network output back to float16" diff --git a/mindspore/train/loss_scale_manager.py b/mindspore/train/loss_scale_manager.py index 1a0f81a1b7f..19eebb09632 100644 --- a/mindspore/train/loss_scale_manager.py +++ b/mindspore/train/loss_scale_manager.py @@ -17,8 +17,6 @@ from .._checkparam import Validator as validator from .. import nn -__all__ = ["LossScaleManager", "FixedLossScaleManager", "DynamicLossScaleManager"] - class LossScaleManager: """Loss scale manager abstract class.""" diff --git a/mindspore/train/serialization.py b/mindspore/train/serialization.py index b9bd0f02596..388d71e44fc 100644 --- a/mindspore/train/serialization.py +++ b/mindspore/train/serialization.py @@ -33,8 +33,6 @@ from mindspore._checkparam import check_input_data, Validator from mindspore.compression.export import quant_export import mindspore.context as context -__all__ = ["save_checkpoint", "load_checkpoint", "load_param_into_net", "export", "parse_print", - "build_searched_strategy", "merge_sliced_parameter"] tensor_to_ms_type = {"Int8": mstype.int8, "Uint8": mstype.uint8, "Int16": mstype.int16, "Uint16": mstype.uint16, "Int32": mstype.int32, "Uint32": mstype.uint32, "Int64": mstype.int64, "Uint64": mstype.uint64, diff --git a/model_zoo/official/cv/alexnet/export.py b/model_zoo/official/cv/alexnet/export.py index f71c63d30ec..f7d08786ad2 100644 --- a/model_zoo/official/cv/alexnet/export.py +++ b/model_zoo/official/cv/alexnet/export.py @@ -20,9 +20,7 @@ import argparse import numpy as np import mindspore as ms -from mindspore import Tensor -from mindspore import context -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import context, Tensor, load_checkpoint, load_param_into_net, export from src.config import alexnet_cifar10_cfg, alexnet_imagenet_cfg from src.alexnet import AlexNet diff --git a/model_zoo/official/cv/cnnctc/export.py b/model_zoo/official/cv/cnnctc/export.py index c053f662115..dae4557524a 100644 --- a/model_zoo/official/cv/cnnctc/export.py +++ b/model_zoo/official/cv/cnnctc/export.py @@ -16,9 +16,8 @@ import argparse import numpy as np -from mindspore import Tensor, context +from mindspore import Tensor, context, load_checkpoint, export import mindspore.common.dtype as mstype -from mindspore.train.serialization import load_checkpoint, export from src.config import Config_CNNCTC from src.cnn_ctc import CNNCTC_Model diff --git a/model_zoo/official/cv/deeplabv3/export.py b/model_zoo/official/cv/deeplabv3/export.py index bcac7b125e1..964b71d2024 100644 --- a/model_zoo/official/cv/deeplabv3/export.py +++ b/model_zoo/official/cv/deeplabv3/export.py @@ -16,10 +16,7 @@ import argparse import numpy as np -from mindspore import Tensor -from mindspore import context -from mindspore.train.serialization import load_checkpoint, load_param_into_net -from mindspore.train.serialization import export +from mindspore import Tensor, context, load_checkpoint, load_param_into_net, export from src.nets import net_factory diff --git a/model_zoo/official/cv/faster_rcnn/export.py b/model_zoo/official/cv/faster_rcnn/export.py index 9816faaf980..cc37345d582 100644 --- a/model_zoo/official/cv/faster_rcnn/export.py +++ b/model_zoo/official/cv/faster_rcnn/export.py @@ -17,8 +17,7 @@ import argparse import numpy as np import mindspore as ms -from mindspore import Tensor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import Tensor, load_checkpoint, load_param_into_net, export from src.FasterRcnn.faster_rcnn_r50 import Faster_Rcnn_Resnet50 from src.config import config diff --git a/model_zoo/official/cv/googlenet/export.py b/model_zoo/official/cv/googlenet/export.py index 2b77fb9b92c..c911ac2ce20 100644 --- a/model_zoo/official/cv/googlenet/export.py +++ b/model_zoo/official/cv/googlenet/export.py @@ -20,8 +20,7 @@ import argparse import numpy as np import mindspore as ms -from mindspore import Tensor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import Tensor, load_checkpoint, load_param_into_net, export from src.config import cifar_cfg, imagenet_cfg from src.googlenet import GoogleNet diff --git a/model_zoo/official/cv/inceptionv3/export.py b/model_zoo/official/cv/inceptionv3/export.py index 8326cf4ed4e..10b1b3b3103 100644 --- a/model_zoo/official/cv/inceptionv3/export.py +++ b/model_zoo/official/cv/inceptionv3/export.py @@ -19,8 +19,7 @@ import argparse import numpy as np import mindspore as ms -from mindspore import Tensor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import Tensor, load_checkpoint, load_param_into_net, export from src.config import config_gpu as cfg from src.inception_v3 import InceptionV3 diff --git a/model_zoo/official/cv/lenet/export.py b/model_zoo/official/cv/lenet/export.py index c3861ac2f32..1f8ddf56e34 100644 --- a/model_zoo/official/cv/lenet/export.py +++ b/model_zoo/official/cv/lenet/export.py @@ -20,9 +20,7 @@ import argparse import numpy as np import mindspore -from mindspore import Tensor -from mindspore import context -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import Tensor, context, load_checkpoint, load_param_into_net, export from src.config import mnist_cfg as cfg from src.lenet import LeNet5 diff --git a/model_zoo/official/cv/lenet_quant/export.py b/model_zoo/official/cv/lenet_quant/export.py index f144ce59364..3d5873e5bd3 100644 --- a/model_zoo/official/cv/lenet_quant/export.py +++ b/model_zoo/official/cv/lenet_quant/export.py @@ -20,10 +20,8 @@ import argparse import numpy as np import mindspore -from mindspore import Tensor -from mindspore import context +from mindspore import Tensor, context, load_checkpoint, load_param_into_net, export from mindspore.compression.quant import QuantizationAwareTraining -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export from src.config import mnist_cfg as cfg from src.lenet_fusion import LeNet5 as LeNet5Fusion diff --git a/model_zoo/official/cv/maskrcnn/export.py b/model_zoo/official/cv/maskrcnn/export.py index f55a3a6f055..14ee325be91 100644 --- a/model_zoo/official/cv/maskrcnn/export.py +++ b/model_zoo/official/cv/maskrcnn/export.py @@ -16,8 +16,7 @@ import argparse import numpy as np -from mindspore import Tensor, context -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import Tensor, context, load_checkpoint, load_param_into_net, export from src.maskrcnn.mask_rcnn_r50 import Mask_Rcnn_Resnet50 from src.config import config diff --git a/model_zoo/official/cv/mobilenetv2/export.py b/model_zoo/official/cv/mobilenetv2/export.py index 58b6a578cf9..e9cf7f9d3c3 100644 --- a/model_zoo/official/cv/mobilenetv2/export.py +++ b/model_zoo/official/cv/mobilenetv2/export.py @@ -16,8 +16,7 @@ mobilenetv2 export mindir. """ import numpy as np -from mindspore import Tensor -from mindspore.train.serialization import export +from mindspore import Tensor, export from src.config import set_config from src.args import export_parse_args from src.models import define_net, load_ckpt diff --git a/model_zoo/official/cv/mobilenetv2_quant/export.py b/model_zoo/official/cv/mobilenetv2_quant/export.py index 5dec710525b..5af9e473bfb 100644 --- a/model_zoo/official/cv/mobilenetv2_quant/export.py +++ b/model_zoo/official/cv/mobilenetv2_quant/export.py @@ -18,9 +18,7 @@ import argparse import numpy as np import mindspore -from mindspore import Tensor -from mindspore import context -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import Tensor, context, load_checkpoint, load_param_into_net, export from mindspore.compression.quant import QuantizationAwareTraining from src.mobilenetV2 import mobilenetV2 diff --git a/model_zoo/official/cv/mobilenetv3/export.py b/model_zoo/official/cv/mobilenetv3/export.py index bfef101ccc8..f073887f685 100644 --- a/model_zoo/official/cv/mobilenetv3/export.py +++ b/model_zoo/official/cv/mobilenetv3/export.py @@ -17,8 +17,7 @@ mobilenetv3 export mindir. """ import argparse import numpy as np -from mindspore import context, Tensor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import context, Tensor, load_checkpoint, load_param_into_net, export from src.config import config_gpu from src.mobilenetV3 import mobilenet_v3_large diff --git a/model_zoo/official/cv/nasnet/export.py b/model_zoo/official/cv/nasnet/export.py index 9afa84a22cd..73907bb2ffb 100755 --- a/model_zoo/official/cv/nasnet/export.py +++ b/model_zoo/official/cv/nasnet/export.py @@ -19,8 +19,7 @@ import argparse import numpy as np import mindspore as ms -from mindspore import Tensor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import Tensor, load_checkpoint, load_param_into_net, export from src.config import nasnet_a_mobile_config_gpu as cfg from src.nasnet_a_mobile import NASNetAMobile diff --git a/model_zoo/official/cv/psenet/export.py b/model_zoo/official/cv/psenet/export.py index 828f60b8444..84ac1ab7c0a 100755 --- a/model_zoo/official/cv/psenet/export.py +++ b/model_zoo/official/cv/psenet/export.py @@ -19,8 +19,7 @@ import argparse import numpy as np import mindspore as ms -from mindspore import Tensor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import Tensor, load_checkpoint, load_param_into_net, export from src.config import config from src.ETSNET.etsnet import ETSNet diff --git a/model_zoo/official/cv/resnet/export.py b/model_zoo/official/cv/resnet/export.py index f3f836c19bd..d0b3866380b 100644 --- a/model_zoo/official/cv/resnet/export.py +++ b/model_zoo/official/cv/resnet/export.py @@ -19,8 +19,7 @@ python export.py import argparse import numpy as np -from mindspore import Tensor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import Tensor, load_checkpoint, load_param_into_net, export if __name__ == '__main__': parser = argparse.ArgumentParser(description='resnet export') diff --git a/model_zoo/official/cv/resnet_thor/export.py b/model_zoo/official/cv/resnet_thor/export.py index f8bbf52ef05..00b91fbe6f2 100644 --- a/model_zoo/official/cv/resnet_thor/export.py +++ b/model_zoo/official/cv/resnet_thor/export.py @@ -16,9 +16,7 @@ import argparse import numpy as np -from mindspore import context -from mindspore import Tensor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import context, Tensor, load_checkpoint, load_param_into_net, export from src.resnet_thor import resnet50 as resnet from src.config import config diff --git a/model_zoo/official/cv/resnext50/export.py b/model_zoo/official/cv/resnext50/export.py index a04f9e9dd7f..09fcd59d797 100644 --- a/model_zoo/official/cv/resnext50/export.py +++ b/model_zoo/official/cv/resnext50/export.py @@ -17,8 +17,7 @@ resnext export mindir. """ import argparse import numpy as np -from mindspore import context, Tensor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import context, Tensor, load_checkpoint, load_param_into_net, export from src.config import config from src.image_classification import get_network diff --git a/model_zoo/official/cv/ssd/export.py b/model_zoo/official/cv/ssd/export.py index 1d5f0087e62..3e2dd293885 100644 --- a/model_zoo/official/cv/ssd/export.py +++ b/model_zoo/official/cv/ssd/export.py @@ -17,8 +17,7 @@ ssd export mindir. """ import argparse import numpy as np -from mindspore import context, Tensor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import context, Tensor, load_checkpoint, load_param_into_net, export from src.ssd import SSD300, ssd_mobilenet_v2 from src.config import config diff --git a/model_zoo/official/cv/unet/export.py b/model_zoo/official/cv/unet/export.py index 12c2b9187c1..6f0390e9455 100644 --- a/model_zoo/official/cv/unet/export.py +++ b/model_zoo/official/cv/unet/export.py @@ -16,8 +16,7 @@ import argparse import numpy as np -from mindspore import Tensor -from mindspore.train.serialization import export, load_checkpoint, load_param_into_net +from mindspore import Tensor, export, load_checkpoint, load_param_into_net from src.unet.unet_model import UNet diff --git a/model_zoo/official/cv/warpctc/export.py b/model_zoo/official/cv/warpctc/export.py index 67880d504f4..c9c4603fb41 100644 --- a/model_zoo/official/cv/warpctc/export.py +++ b/model_zoo/official/cv/warpctc/export.py @@ -16,8 +16,7 @@ import argparse import numpy as np -from mindspore import Tensor, context -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import Tensor, context, load_checkpoint, load_param_into_net, export from src.warpctc import StackedRNN from src.config import config diff --git a/tests/st/quantization/lenet_quant/test_lenet_quant.py b/tests/st/quantization/lenet_quant/test_lenet_quant.py index 728a58943c8..96bb068bb80 100644 --- a/tests/st/quantization/lenet_quant/test_lenet_quant.py +++ b/tests/st/quantization/lenet_quant/test_lenet_quant.py @@ -24,7 +24,7 @@ from mindspore.common import dtype as mstype import mindspore.nn as nn from mindspore.nn.metrics import Accuracy from mindspore.train.callback import ModelCheckpoint, CheckpointConfig, LossMonitor, TimeMonitor -from mindspore.train.serialization import load_checkpoint, load_param_into_net, export +from mindspore import load_checkpoint, load_param_into_net, export from mindspore.train import Model from mindspore.compression.quant import QuantizationAwareTraining from mindspore.compression.quant.quant_utils import load_nonquant_param_into_quant_net