提交 4bf3c8c5 编写于 作者: M minqiyang

Use six.moves to migrate zip, map, reduce and pickle in Python2 to Python3

上级 91f0573b
......@@ -28,11 +28,12 @@ images per class.
"""
import pickle
import itertools
import numpy
import paddle.dataset.common
import tarfile
from six.moves import zip
from six.moves import cPickle as pickle
__all__ = ['train100', 'test100', 'train10', 'test10', 'convert']
......
......@@ -20,9 +20,8 @@ import shutil
import sys
import importlib
import paddle.dataset
import pickle
import six.moves.cPickle as pickle
import glob
import pickle as pickle
__all__ = [
'DATA_HOME',
......
......@@ -24,6 +24,7 @@ import tarfile
import gzip
import itertools
import paddle.dataset.common
from six.moves import zip
__all__ = ['test, get_dict', 'get_embedding', 'convert']
......
......@@ -28,7 +28,6 @@ Graphics and Image Processing (2008)
http://www.robots.ox.ac.uk/~vgg/publications/papers/nilsback08.{pdf,ps.gz}.
"""
import pickle
import itertools
import functools
from .common import download
......@@ -39,6 +38,8 @@ from paddle.reader import *
import os
import numpy as np
from multiprocessing import cpu_count
from six.moves import cPickle as pickle
from six.moves import zip
__all__ = ['train', 'test', 'valid']
DATA_URL = 'http://www.robots.ox.ac.uk/~vgg/data/flowers/102/102flowers.tgz'
......
......@@ -36,7 +36,7 @@ except ImportError:
cv2 = None
import os
import tarfile
import pickle
import six.moves.cPickle as pickle
__all__ = [
"load_image_bytes", "load_image", "resize_short", "to_chw", "center_crop",
......
......@@ -963,9 +963,9 @@ class Block(object):
raise ValueError("Var {0} is not found recursively".format(name))
def all_parameters(self):
return list(self.iter_parameters())
return list(self._iter_parameters())
def iter_parameters(self):
def _iter_parameters(self):
return (item[1] for item in list(self.vars.items())
if isinstance(item[1], Parameter))
......@@ -1199,7 +1199,7 @@ class Block(object):
if not isinstance(other, Block):
raise TypeError(
"_copy_param_info_from should be invoked with Block")
for p in other.iter_parameters():
for p in other._iter_parameters():
assert isinstance(p, Parameter)
v = self.vars.get(p.name, None)
if v is None:
......
......@@ -20,6 +20,7 @@ from . import unique_name
from paddle.fluid.initializer import Constant, Xavier
from .param_attr import ParamAttr, WeightNormParamAttr
from . import core
from six.moves import zip
class LayerHelper(object):
......
......@@ -28,11 +28,12 @@ images per class.
"""
import pickle
import itertools
import numpy
import paddle.v2.dataset.common
import tarfile
from six.moves import cPickle as pickle
from six.moves import zip
__all__ = ['train10']
......
......@@ -17,6 +17,7 @@ from .. import core
from ..framework import Program, default_main_program, Parameter
from ..backward import _rename_arg_
from functools import reduce
from six.moves import range
dtype_to_size = {
core.VarDesc.VarType.FP16: 2,
......
......@@ -67,7 +67,7 @@ def recordio(paths, buf_size=100):
import recordio as rec
import paddle.reader.decorator as dec
import pickle as pickle
import six.moves.cPickle as pickle
def reader():
if isinstance(paths, str):
......
......@@ -22,6 +22,8 @@ import subprocess
from six.moves.queue import Queue
from six.moves import zip_longest
from six.moves import map
from six.moves import zip
import itertools
import random
import zlib
......
......@@ -42,7 +42,7 @@ except ImportError:
try:
import cPickle as pickle
except ImportError:
import pickle
import six.moves.cPickle as pickle
import io
......
......@@ -20,7 +20,7 @@ from .utils import deprecated
try:
import cPickle as pickle
except ImportError:
import pickle
import six.moves.cPickle as pickle
__all__ = ['define_py_data_sources2']
......
......@@ -28,7 +28,7 @@ from .default_decorators import *
try:
import cPickle as pickle
except ImportError:
import pickle
import six.moves.cPickle as pickle
import copy
__all__ = [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册