-  3.39.25
pyfaust.factparams.StoppingCriterion Class Reference

This class defines a StoppingCriterion for PALM4MSA algorithms. More...

Public Member Functions

def __init__ (self, num_its=DEFAULT_NUMITS, tol=None, maxiter=DEFAULT_MAXITER, relerr=False, relmat=None, erreps=None)
 Class constructor. More...
 
def __str__ (self)
 Converts StoppingCriterion to a str. More...
 
def __repr__ (self)
 Returns the StoppingCriterion object representation. More...
 

Public Attributes

 tol
 
 num_its
 
 maxiter
 
 relerr
 
 erreps
 

Static Public Attributes

int DEFAULT_MAXITER = 10000
 
float DEFAULT_TOL = 0.3
 
int DEFAULT_NUMITS = 500
 

Detailed Description

This class defines a StoppingCriterion for PALM4MSA algorithms.

A stopping criterion can be of two kinds:

  • number of iterations,
  • error threshold.
See also
StoppingCriterion.__init__

Constructor & Destructor Documentation

◆ __init__()

def pyfaust.factparams.StoppingCriterion.__init__ (   self,
  num_its = DEFAULT_NUMITS,
  tol = None,
  maxiter = DEFAULT_MAXITER,
  relerr = False,
  relmat = None,
  erreps = None 
)

Class constructor.

Parameters
num_its(int) the fixed number of iterations of the algorithm. By default the value is DEFAULT_NUMITS. The constructor will fail if arguments num_its and tol are used together.
tol(float) error target according to the algorithm is stopped. The constructor will fail if arguments num_its and tol are used together.
maxiter(int) The maximum number of iterations to run the algorithm, whatever is the criterion used (tol or num_its).
relerr(bool) if False the tol error defines an absolute error, otherwise it defines a relative error (in this case the 'relmat' matrix will be used to convert internally the given 'tol' value to the corresponding absolute error).
relmat(bool) The matrix against which is defined the relative error. if relerr is True, this argument is mandatory.
erreps(float) defines the epsilon on the approximation error between two PALM4MSA iterations. If the error doesn't improve more than erreps then the algorithm stops (warning: this argument is only supported by the 2020 backend of PALM4MSA implementations).

Examples

>>> from pyfaust.factparams import StoppingCriterion
>>> from numpy.random import rand, seed
>>> seed(42) # just for reproducibility
>>> s = StoppingCriterion()
>>> print(s)

num_its: 500, maxiter: 10000

>>> s = StoppingCriterion(5)
>>> print(s)

num_its: 5, maxiter: 10000

>>> s = StoppingCriterion(tol=.5)
>>> print(s)

tol: 0.5, relerr: False, maxiter: 10000

>>> s = StoppingCriterion(tol=.2, relerr=True, relmat=rand(10,10))
>>> print(s)

tol: 1.1111883397755122, relerr: True, maxiter: 10000

Member Function Documentation

◆ __repr__()

def pyfaust.factparams.StoppingCriterion.__repr__ (   self)

Returns the StoppingCriterion object representation.

◆ __str__()

def pyfaust.factparams.StoppingCriterion.__str__ (   self)

Converts StoppingCriterion to a str.

Member Data Documentation

◆ DEFAULT_MAXITER

int pyfaust.factparams.StoppingCriterion.DEFAULT_MAXITER = 10000
static

◆ DEFAULT_NUMITS

int pyfaust.factparams.StoppingCriterion.DEFAULT_NUMITS = 500
static

◆ DEFAULT_TOL

float pyfaust.factparams.StoppingCriterion.DEFAULT_TOL = 0.3
static

◆ erreps

pyfaust.factparams.StoppingCriterion.erreps

◆ maxiter

pyfaust.factparams.StoppingCriterion.maxiter

◆ num_its

pyfaust.factparams.StoppingCriterion.num_its

◆ relerr

pyfaust.factparams.StoppingCriterion.relerr

◆ tol

pyfaust.factparams.StoppingCriterion.tol

The documentation for this class was generated from the following file:
pyfaust.seed
def seed(s)
(Re)Initializes the pyfaust pseudo-random generator.
Definition: __init__.py:5334
pyfaust.rand
def rand(num_rows, num_cols, num_factors=None, dim_sizes=None, density=None, fac_type='sparse', per_row=True, dev='cpu', dtype='float64', field=None, seed=0)
Generates a random Faust.
Definition: __init__.py:5016
pyfaust.factparams
The module for the parameterization of FAuST's algorithms (Palm4MSA and Hierarchical Factorization)....
Definition: factparams.py:1