utils.py 1.1 KB
Newer Older
zhaoyijin666's avatar
zhaoyijin666 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging

logging.basicConfig()
logger = logging.getLogger("paddle")
logger.setLevel(logging.INFO)


class TaskMode(object):
    """
    TaskMode
    """
    TRAIN_MODE = 0
    TEST_MODE = 1
    INFER_MODE = 2

    def __init__(self, mode):
        """

        :param mode:
        """
        self.mode = mode

    def is_train(self):
        """

        :return:
        """
        return self.mode == self.TRAIN_MODE

    def is_test(self):
        """

        :return:
        """
        return self.mode == self.TEST_MODE

    def is_infer(self):
        """

        :return:
        """
        return self.mode == self.INFER_MODE

    @staticmethod
    def create_train():
        """

        :return:
        """
        return TaskMode(TaskMode.TRAIN_MODE)

    @staticmethod
    def create_test():
        """

        :return:
        """
        return TaskMode(TaskMode.TEST_MODE)

    @staticmethod
    def create_infer():
        """

        :return:
        """
        return TaskMode(TaskMode.INFER_MODE)