probabilistic_model.probabilistic_circuit.jax.discrete_layer#

Classes#

DiscreteLayer

Abstract base class for univariate input units.

Module Contents#

class probabilistic_model.probabilistic_circuit.jax.discrete_layer.DiscreteLayer(variable: int, log_probabilities: jax.numpy.array)#

Bases: probabilistic_model.probabilistic_circuit.jax.inner_layer.InputLayer

Abstract base class for univariate input units.

Input layers contain only one type of distribution such that the vectorization of the log likelihood calculation works without bottleneck statements like if/else or loops.

log_probabilities: jax.numpy.array#

The logarithm of probability for each state of the variable.

The shape is (#nodes, #states).

classmethod nx_classes() Tuple[Type, Ellipsis]#
Returns:

The tuple of matching classes of the layer in the probabilistic_model.probabilistic_circuit.rx package.

validate()#

Validate the parameters and their layouts.

property log_normalization_constant: jax.numpy.array#
property normalized_log_probabilities: jax.numpy.array#
property number_of_nodes: int#
Returns:

The number of nodes in the layer.

log_likelihood_of_nodes_single(x: jax.numpy.array) jax.numpy.array#

Calculate the log-likelihood of the distribution.

Parameters:

x – The input vector.

Returns:

The log-likelihood of every node in the layer for x.

classmethod create_layer_from_nodes_with_same_type_and_scope(nodes: List[probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.UnivariateDiscreteLeaf], child_layers: List[probabilistic_model.probabilistic_circuit.jax.NXConverterLayer], progress_bar: bool = True) probabilistic_model.probabilistic_circuit.jax.NXConverterLayer#

Create a layer from a list of nodes with the same type and scope.

to_json() Dict[str, Any]#
classmethod _from_json(data: Dict[str, Any]) typing_extensions.Self#

Create a variable from a json dict. This method is called from the from_json method after the correct subclass is determined and should be overwritten by the respective subclass.

Parameters:

data – The json dict

Returns:

The deserialized object

to_nx(variables: sortedcontainers.SortedSet[random_events.variable.Variable], result: probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.ProbabilisticCircuit, progress_bar: typing_extensions.Optional[tqdm.tqdm] = None) List[probabilistic_model.probabilistic_circuit.rx.probabilistic_circuit.Unit]#

Convert the layer to a networkx circuit. For every node in this circuit, a corresponding node in the networkx circuit is created. The nodes all belong to the same circuit.

Parameters:
  • variables – The variables of the circuit.

  • result – The resulting circuit to write into

  • progress_bar – A progress bar to show the progress.

Returns:

The nodes of the networkx circuit.