Esempio n. 1
0
 def __init__(self, input_variable=Variable, name=str, alpha = 0.25):
     self.input_variables = input_variable
     self.output_variables = Variable(self.input_variables.shape, name='out', scope=name)
     self.alpha = alpha
     self.momentum  = 0.9
     self.eta = 1e-4
     Operator.__init__(self, name, self.input_variables, self.output_variables)
Esempio n. 2
0
    def __init__(self, phone_number, phone_passwd):
        self.phone_number = phone_number
        self.phone_passwd = phone_passwd

        Operator.__init__(self, phone_number, phone_passwd)
        Operator.get_task_no(self, phone_number=phone_number)

        self.homepage = 'http://www.10010.com'
        self.login_url = 'https://uac.10010.com/portal/homeLogin'
        self.driver = None

        ua = ("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 " +
              "(KHTML, like Gecko) Chrome/45.0.2454.93 Safari/537.36")
        self.header = {
            "HOST": "iservice.10010.com",
            "Origin": "http://iservice.10010.com",
            "X-Requested-With": "XMLHttpRequest",
            "Referer": r"https://uac.10010.com/portal/homeLogin",
            "Accept": r"application/json, text/javascript, */*; q=0.01",
            "User-Agent": ua,
            "Accept-Encoding": r"deflate",
            "Accept-Language": r"zh-CN,zh;q=0.8",
            "Upgrade-Insecure-Requests": "1",
            "Content-Type": r"application/x-www-form-urlencoded;charset=UTF-8"
        }

        # 2.2 创建带上述头信息的会话
        self.ses = requests.Session()
        self.ses.headers = self.header
    def __init__(self, kernel: Callable, lower: float, upper: float, grid_size: int,
                 observations: np.ndarray, sample_size: int, order: int = 1, adjoint: bool = False,
                 quadrature: str = 'rectangle', **kwargs):
        """
        Instance of iterated Tikhonov solver for inverse problem in Poisson noise with integral operator.
        :param kernel: Kernel of the integral operator.
        :type kernel: Callable
        :param lower: Lower end of the interval on which the operator is defined.
        :type lower: float
        :param upper: Upper end of the interval on which the operator is defined.
        :type upper: float
        :param grid_size: Size pf grid used to approximate the operator.
        :type grid_size: int
        :param observations: Observations used for the estimation.
        :type observations: numpy.ndarray
        :param sample_size: Theoretical sample size (n).
        :type sample_size: int
        :param order: Order of the iterated algorithm. Estimator for each regularization parameter is obtained after
        order iterations. Ordinary Tikhonov estimator is obtained for order = 1.
        :type order: int (default: 1)
        :param adjoint: Whether the operator is adjoint (True) or not (False).
        :type adjoint: boolean (default: False)
        :param quadrature: Type of quadrature used to approximate integrals.
        :type quadrature: str (default: recatngle)
        :param kwargs: Possible arguments:
            - tau: Parameter used to rescale the obtained values of estimated noise level (float or int, default: 1).
            - parameter_space_size: Number of possible values of regularization parameter calculated as values between
            10^(-15) and 1 with step dictated by the parameter_space_size (int, default: 100).
             - grid_max_iter: Maximum number of iterations of routine looking for the reasonable starting point for grid
             search. In each iteration, parameter grid is shifted by 1. In case no reasonable starting point has been found,
             RuntimeWarning is raised (int, default: 50).

        """
        Operator.__init__(self, kernel, lower, upper, grid_size, adjoint, quadrature)
        EstimatorDiscretize.__init__(self, kernel, lower, upper, grid_size, observations, sample_size, quadrature)
        assert isinstance(order, int), 'Please specify the order as an integer'
        self.__order: int = order
        self.grid_max_iter: int = kwargs.get('grid_max_iter', 50)
        assert isinstance(self.grid_max_iter, int)
        self.__tau: float = kwargs.get('tau', 1.)
        assert isinstance(self.__tau, (int, float)), 'tau must be a number'
        self.__parameter_space_size: int = kwargs.get('parameter_space_size', 100)
        try:
            assert isinstance(self.__parameter_space_size, int)
        except AssertionError:
            warn('Parameter space size is not an integer, falling back to default value')
            self.__parameter_space_size = 100
        self.__parameter_grid: np.ndarray = np.flip(np.power(10, np.linspace(-15, 0, self.__parameter_space_size)))
        self.initial: cp.ndarray = cp.empty(self.grid_size, dtype=cp.float64)
        self.previous: cp.ndarray = cp.empty(self.grid_size, dtype=cp.float64)
        self.current: cp.ndarray = cp.empty(self.grid_size, dtype=cp.float64)
        self.__solution: cp.ndarray = cp.empty(self.initial.shape, dtype=cp.float64)
        Operator.approximate(self)
        self.__KHK: cp.ndarray = self.__premultiplication(self.KH, self.K)
        self.identity: cp.ndarray = cp.identity(self.grid_size, dtype=cp.float64)
        EstimatorDiscretize.estimate_q(self)
        EstimatorDiscretize.estimate_delta(self)
        self.__grid: np.ndarray = getattr(super(), quadrature + '_grid')()
        self.__define_grid()
Esempio n. 4
0
 def __init__(self, id, name, capacity=1, schedulingRule="FIFO", **kw):
     Operator.__init__(self,
                       id=id,
                       name=name,
                       capacity=capacity,
                       schedulingRule=schedulingRule)
     from Globals import G
     G.OperatorManagedJobsList.append(self)
 def __init__(self, kernel: Callable, lower: float, upper: float, grid_size: int,
              observations: np.ndarray, sample_size: int, adjoint: bool = False, quadrature: str = 'rectangle',
              **kwargs):
     """
     Instance of Landweber solver for inverse problem in Poisson noise with integral operator.
     :param kernel: Kernel of the integral operator.
     :type kernel: Callable
     :param lower: Lower end of the interval on which the operator is defined.
     :type lower: float
     :param upper: Upper end of the interval on which the operator is defined.
     :type upper: float
     :param grid_size: Size pf grid used to approximate the operator.
     :type grid_size: int
     :param observations: Observations used for the estimation.
     :type observations: numpy.ndarray
     :param sample_size: Theoretical sample size (n).
     :type sample_size: int
     :param adjoint: Whether the operator is adjoint (True) or not (False).
     :type adjoint: boolean (default: False)
     :param quadrature: Type of quadrature used to approximate integrals.
     :type quadrature: str (default: recatngle)
     :param kwargs: Possible arguments:
         - max_iter: The maximum number of iterations of the algorithm (int, default: 1000).
         - tau: Parameter used to rescale the obtained values of estimated noise level (float or int, default: 1).
         - initial: Initial guess for the solution (numpy.ndarray, default: 0).
         - relaxation: Parameter used in the iteration of the algorithm (step size, omega). This approximate square norm
          of an operator is divide by the value of relaxation parameter (float or int, default: 2).
     """
     Operator.__init__(self, kernel, lower, upper, grid_size, adjoint, quadrature)
     EstimatorDiscretize.__init__(self, kernel, lower, upper, grid_size, observations, sample_size, quadrature)
     self.max_iter: int = kwargs.get('max_iter', 100)
     self.__tau: float = kwargs.get('tau', 1.)
     assert isinstance(self.__tau, (int, float)), 'tau must be a number'
     self.initial: cp.ndarray = kwargs.get('initial_guess',
                                           cp.repeat(cp.array([0]), self.grid_size).astype(cp.float64))
     try:
         assert isinstance(self.initial, cp.ndarray)
     except AssertionError:
         warn('Initial guess is not a cupy array, falling back to default value', RuntimeWarning)
         self.initial: cp.ndarray = cp.repeat(cp.array([0]), self.grid_size).astype(cp.float64)
     self.previous: cp.ndarray = cp.empty(self.grid_size, dtype=cp.float64)
     self.current: cp.ndarray = cp.empty(self.grid_size, dtype=cp.float64)
     Operator.approximate(self)
     self.__KHK: cp.ndarray = self.__premultiplication(self.KH, self.K)
     self.__relaxation: float = kwargs.get('relaxation', 0.5)
     assert isinstance(self.__relaxation, (int, float)), 'Relaxation parameter must be a number'
     self.__relaxation = self.__relaxation / (np.max(np.linalg.svd(cp.asnumpy(self.KHK), compute_uv=False, hermitian=True)))
     EstimatorDiscretize.estimate_q(self)
     EstimatorDiscretize.estimate_delta(self)
     self.__grid: np.ndarray = getattr(super(), quadrature + '_grid')()
Esempio n. 6
0
 def __init__(self,
              kernel: Callable,
              lower: Union[float, int],
              upper: Union[float, int],
              grid_size: int,
              observations: np.ndarray,
              sample_size: int,
              adjoint: bool = False,
              quadrature: str = 'rectangle',
              **kwargs):
     """
     Instance of TSVD solver for inverse problem in Poisson noise with integral operator.
     :param kernel: Kernel of the integral operator.
     :type kernel: Callable
     :param lower: Lower end of the interval on which the operator is defined.
     :type lower: float
     :param upper: Upper end of the interval on which the operator is defined.
     :type upper: float
     :param grid_size: Size pf grid used to approximate the operator.
     :type grid_size: int
     :param observations: Observations used for the estimation.
     :type observations: numpy.ndarray
     :param sample_size: Theoretical sample size (n).
     :type sample_size: int
     :param adjoint: Whether the operator is adjoint (True) or not (False).
     :type adjoint: boolean (default: False)
     :param quadrature: Type of quadrature used to approximate integrals.
     :type quadrature: str (default: recatngle)
     :param kwargs: Possible arguments:
         - tau: Parameter used to rescale the obtained values of estimated noise level (float or int, default: 1).
     """
     Operator.__init__(self, kernel, lower, upper, grid_size, adjoint,
                       quadrature)
     EstimatorDiscretize.__init__(self, kernel, lower, upper, grid_size,
                                  observations, sample_size, quadrature)
     self.__tau: Union[float, int] = kwargs.get('tau', 1.)
     assert isinstance(self.__tau, (int, float)), 'tau must be a number'
     self.previous: cp.ndarray = cp.empty(self.grid_size, dtype=cp.float64)
     self.current: cp.ndarray = cp.empty(self.grid_size, dtype=cp.float64)
     Operator.approximate(self)
     self.__KHK: cp.ndarray = self.__premultiplication(self.KH, self.K)
     EstimatorDiscretize.estimate_q(self)
     EstimatorDiscretize.estimate_delta(self)
     self.__U: cp.ndarray = cp.zeros((self.grid_size, self.grid_size))
     self.__V: cp.ndarray = cp.zeros((self.grid_size, self.grid_size))
     self.__D: cp.ndarray = cp.zeros((self.grid_size, ))
     self.__U, self.__D, self.__V = self.decomposition(
         self.KHK, self.grid_size)
     self.__grid: np.ndarray = getattr(super(), quadrature + '_grid')()
Esempio n. 7
0
 def __init__(self):
     Operator.__init__(self)
     self.symbol = '/'
     self.precedence = 2
     self.associative = 'L'
Esempio n. 8
0
 def __init__(self, id, name, capacity=1,**kw):
     Operator.__init__(self,id=id, name=name, capacity=capacity)
     self.type="Repairman"
     from Globals import G
     G.RepairmanList.append(self) 
Esempio n. 9
0
 def __init__(self, id, name, capacity=1,schedulingRule="FIFO"):
     Operator.__init__(self,id=id,name=name,capacity=capacity,schedulingRule=schedulingRule)
     self.operatorAssignedTo=None
Esempio n. 10
0
 def __init__(self):
     Operator.__init__(self)
     self.symbol = '^'
     self.precedence = 4
     self.associative = 'R'
Esempio n. 11
0
 def __init__(self, left, right):
     """
     Constructor.
     """
     Operator.__init__(self, left, right)
Esempio n. 12
0
 def __init__(self, id, name, capacity=1,schedulingRule="FIFO",**kw):
     Operator.__init__(self,id=id,name=name,capacity=capacity,schedulingRule=schedulingRule)
     from Globals import G
     G.OperatorManagedJobsList.append(self) 
Esempio n. 13
0
 def __init__(self, input_variable=Variable, name=str):
     self.input_variables = input_variable
     self.output_variables = Variable(self.input_variables.shape, name='out', scope=name)
     Operator.__init__(self, name, self.input_variables, self.output_variables)
Esempio n. 14
0
 def __init__(self, input_variable=Variable, name=str, alpha = 0.01):
     self.input_variables = input_variable
     self.output_variables = Variable(self.input_variables.shape, name='out', scope=name)
     self.alpha = alpha
     Operator.__init__(self, name, self.input_variables, self.output_variables)
Esempio n. 15
0
 def __init__(self, regex, *args):
     """
     Constructor.
     """
     Operator.__init__(self, *args)
     self.regex = re.compile(regex)
Esempio n. 16
0
 def __init__(self, id, name, capacity=1, **kw):
     Operator.__init__(self, id=id, name=name, capacity=capacity)
     self.type = "Repairman"
     from Globals import G
     G.RepairmanList.append(self)