update static method by trying-catch (#391)
parent
65003348d6
commit
bec79a0084
|
@ -19,6 +19,7 @@ from __future__ import print_function
|
|||
import os
|
||||
import sys
|
||||
|
||||
import paddle
|
||||
import paddle.fluid as fluid
|
||||
|
||||
from ppcls.modeling import get_architectures
|
||||
|
@ -134,3 +135,10 @@ def check_function_params(config, key):
|
|||
('params is required in {} config'.format(key))
|
||||
assert isinstance(params, dict), \
|
||||
('the params in {} config should be a dict'.format(key))
|
||||
|
||||
|
||||
def enable_static_mode():
|
||||
try:
|
||||
paddle.enable_static()
|
||||
except:
|
||||
pass
|
||||
|
|
|
@ -32,6 +32,7 @@ import program
|
|||
from ppcls.data import Reader
|
||||
from ppcls.utils.config import get_config
|
||||
from ppcls.utils.save_load import init_model
|
||||
from ppcls.utils.check import enable_static_mode
|
||||
|
||||
from paddle.fluid.incubate.fleet.collective import fleet
|
||||
from paddle.fluid.incubate.fleet.base import role_maker
|
||||
|
@ -84,6 +85,6 @@ def main(args):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
paddle.enable_static()
|
||||
enable_static_mode()
|
||||
args = parse_args()
|
||||
main(args)
|
||||
|
|
|
@ -31,6 +31,7 @@ import program
|
|||
from ppcls.data import Reader
|
||||
from ppcls.utils.config import get_config
|
||||
from ppcls.utils.save_load import init_model
|
||||
from ppcls.utils.check import enable_static_mode
|
||||
|
||||
|
||||
def parse_args():
|
||||
|
@ -77,6 +78,6 @@ def main(args):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
paddle.enable_static()
|
||||
enable_static_mode()
|
||||
args = parse_args()
|
||||
main(args)
|
||||
|
|
|
@ -21,6 +21,7 @@ sys.path.append(os.path.abspath(os.path.join(__dir__, '../')))
|
|||
import argparse
|
||||
|
||||
from ppcls.modeling import architectures
|
||||
from ppcls.utils.check import enable_static_mode
|
||||
import paddle
|
||||
import paddle.fluid as fluid
|
||||
|
||||
|
@ -82,5 +83,5 @@ def main():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
paddle.enable_static()
|
||||
enable_static_mode()
|
||||
main()
|
||||
|
|
|
@ -24,6 +24,7 @@ import paddle
|
|||
import paddle.fluid as fluid
|
||||
|
||||
from ppcls.modeling import architectures
|
||||
from ppcls.utils.check import enable_static_mode
|
||||
import utils
|
||||
|
||||
|
||||
|
@ -145,5 +146,5 @@ def main():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
paddle.enable_static()
|
||||
enable_static_mode()
|
||||
main()
|
||||
|
|
|
@ -11,6 +11,11 @@
|
|||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
import os
|
||||
import sys
|
||||
__dir__ = os.path.dirname(os.path.abspath(__file__))
|
||||
sys.path.append(__dir__)
|
||||
sys.path.append(os.path.abspath(os.path.join(__dir__, '../')))
|
||||
|
||||
import utils
|
||||
import argparse
|
||||
|
@ -19,6 +24,8 @@ import numpy as np
|
|||
import paddle
|
||||
import paddle.fluid as fluid
|
||||
|
||||
from ppcls.utils.check import enable_static_mode
|
||||
|
||||
|
||||
def parse_args():
|
||||
def str2bool(v):
|
||||
|
@ -100,5 +107,5 @@ def main():
|
|||
|
||||
|
||||
if __name__ == "__main__":
|
||||
paddle.enable_static()
|
||||
enable_static_mode()
|
||||
main()
|
||||
|
|
|
@ -33,6 +33,7 @@ from paddle.fluid.incubate.fleet.collective import fleet
|
|||
from ppcls.data import Reader
|
||||
from ppcls.utils.config import get_config
|
||||
from ppcls.utils.save_load import init_model, save_model
|
||||
from ppcls.utils.check import enable_static_mode
|
||||
from ppcls.utils import logger
|
||||
import program
|
||||
|
||||
|
@ -155,6 +156,6 @@ def main(args):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
paddle.enable_static()
|
||||
enable_static_mode()
|
||||
args = parse_args()
|
||||
main(args)
|
||||
|
|
|
@ -31,6 +31,7 @@ import paddle.fluid as fluid
|
|||
from ppcls.data import Reader
|
||||
from ppcls.utils.config import get_config
|
||||
from ppcls.utils.save_load import init_model, save_model
|
||||
from ppcls.utils.check import enable_static_mode
|
||||
from ppcls.utils import logger
|
||||
import program
|
||||
|
||||
|
@ -164,6 +165,6 @@ def main(args):
|
|||
|
||||
|
||||
if __name__ == '__main__':
|
||||
paddle.enable_static()
|
||||
enable_static_mode()
|
||||
args = parse_args()
|
||||
main(args)
|
||||
|
|
Loading…
Reference in New Issue