MarkovChainModel

class pycave.bayes.markov_chain.MarkovChainModel(config)[source]

Bases: Configurable[MarkovChainModelConfig], Module

PyTorch module for a Markov chain.

The initial state probabilities as well as the transition probabilities are non-trainable parameters.

Parameters:

config (MarkovChainModelConfig) -- The configuration to use for initializing the module's buffers.

Methods

forward

Computes the log-probability of observing each of the provided sequences.

reset_parameters

Resets the parameters of the Markov model.

sample

Samples random sequences from the Markov chain.

stationary_distribution

Computes the stationary distribution of the Markov chain using power iteration.

Inherited Methods

load

Loads the module's configurations and parameters from files in the specified directory at first.

save

Saves the module's configuration and parameters to files in the specified directory.

Attributes

initial_probs

The probabilities for the initial states, buffer of shape [num_states].

transition_probs

The transition probabilities between all states, buffer of shape [num_states, num_states].