opt_einsum.path_random.RandomGreedy¶
- class opt_einsum.path_random.RandomGreedy(cost_fn='memory-removed-jitter', temperature=1.0, rel_temperature=True, nbranch=8, **kwargs)[source]¶
- Parameters:
cost_fn (callable, optional) – A function that returns a heuristic ‘cost’ of a potential contraction with which to sort candidates. Should have signature
cost_fn(size12, size1, size2, k12, k1, k2).temperature (float, optional) – When choosing a possible contraction, its relative probability will be proportional to
exp(-cost / temperature). Thus the largertemperatureis, the further random paths will stray from the normal ‘greedy’ path. Conversely, if set to zero, only paths with exactly the same cost as the best at each step will be explored.rel_temperature (bool, optional) – Whether to normalize the
temperatureat each step to the scale of the best cost. This is generally beneficial as the magnitude of costs can vary significantly throughout a contraction. If False, the algorithm will end up branching when the absolute cost is low, but stick to the ‘greedy’ path when the cost is high - this can also be beneficial.nbranch (int, optional) – How many potential paths to calculate probability for and choose from at each step.
kwargs – Supplied to RandomOptimizer.
See also
- __init__(cost_fn='memory-removed-jitter', temperature=1.0, rel_temperature=True, nbranch=8, **kwargs)[source]¶
Methods
__call__(inputs, output, size_dict, memory_limit)Call self as a function.
__del__()__delattr__(name, /)Implement delattr(self, name).
__dir__()Default dir() implementation.
__eq__(value, /)Return self==value.
__format__(format_spec, /)Default object formatter.
__ge__(value, /)Return self>=value.
__getattribute__(name, /)Return getattr(self, name).
__getstate__()Helper for pickle.
__gt__(value, /)Return self>value.
__hash__()Return hash(self).
__init__([cost_fn, temperature, ...])__init_subclass__This method is called when a class is subclassed.
__le__(value, /)Return self<=value.
__lt__(value, /)Return self<value.
__ne__(value, /)Return self!=value.
__new__(**kwargs)__reduce__()Helper for pickle.
__reduce_ex__(protocol, /)Helper for pickle.
__repr__()Return repr(self).
__setattr__(name, value, /)Implement setattr(self, name, value).
__sizeof__()Size of object in memory, in bytes.
__str__()Return str(self).
__subclasshook__Abstract classes can override this to customize issubclass().
_cancel_futures()_check_args_against_first_call(inputs, ...)Utility that stateful optimizers can use to ensure they are not called with different contractions across separate runs.
_gen_results_parallel(repeats, trial_fn, args)Lazily generate results from an executor without submitting all jobs at once.
setup(inputs, output, size_dict)Attributes
__annotations____dict____doc____module____weakref__list of weak references to the object
choose_fnThe function that chooses which contraction to take - make this a property so that
temperatureandnbranchetc.parallelpathThe best path found so far.