AlgoVision Core

class Input(name, shape=None, dtype=None)[source]
__init__(name, shape=None, dtype=None)[source]
checks(x)[source]
class Output(name, shape=None, dtype=None)[source]
__init__(name, shape=None, dtype=None)[source]
checks(x)[source]
class Variable(name, initial_value)[source]
__init__(name, initial_value)[source]
get_value()[source]
class VariableInt(name, initial_value)[source]
__init__(name, initial_value)[source]
checks_and_cast()[source]
get_value()[source]
Var

alias of algovision.core.Variable

VarInt

alias of algovision.core.VariableInt

class State(input_names, input_values, variables, variable_ints, batch_size)[source]
__init__(input_names, input_values, variables, variable_ints, batch_size)[source]
return_outputs(outputs: List[algovision.core.Output]) Union[torch.Tensor, Tuple[torch.Tensor]][source]
merge(to_merge, p)[source]

(Internal) Merges two states with where the new tensor is used to the extent of \(p\) .

For any tensors \(t_1, t_2\) (self, to_merge) and probability \(p\) , the new tensor and probability \(t^\prime\) is defined as

\[t^\prime = t_1 \cdot (p-1) + t_2 \cdot p\]
probabilistic_update(key, value, p)[source]
reset()[source]

(Internal) Resets all tensors to zero.

add(to_add, p)[source]

(Internal) Merges two states by adding to_add weighted by p. Except of VariableInt types; there, the new value is used.

clone()[source]

Duplicates a State .

Does not duplicate the internal objects, i.e., copy.copy() instead of copy.deepcopy().

to(device)[source]
update(new_values: dict)[source]
get_device()[source]
class AlgoModule[source]
__init__()[source]
set_hyperparameters(beta, max_iter, epsilon, hard, debug)[source]
class Condition(left, right, beta=None)[source]
__init__(left, right, beta=None)[source]
get_left(state)[source]
get_right(state)[source]
class Algorithm(*sequence, beta=10.0, max_iter=1024, epsilon=1e-05, hard=False, debug=False)[source]
__init__(*sequence, beta=10.0, max_iter=1024, epsilon=1e-05, hard=False, debug=False)[source]

Initializes internal Module state, shared by both nn.Module and ScriptModule.

forward(*inputs: torch.Tensor) Union[torch.Tensor, Tuple[torch.Tensor]][source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool