The likelihood_omhn submodule#
This submodule contains functions that can be used to compute the scores and gradients for the oMHN.
- mhn.training.likelihood_omhn.cpu_gradient_and_score(omega_theta: ndarray, mutation_data: StateContainer) tuple[ndarray, float]#
Computes the log-likelihood score and gradient on the CPU.
- Parameters:
omega_theta (np.ndarray) – Theta matrix for the oMHN (shape: (n+1) x n), where the last row contains observation rates.
mutation_data (StateContainer) – Data used for training.
- Returns:
The gradient (as a numpy array) and the score (as a float).
- Return type:
tuple[np.ndarray, float]
- mhn.training.likelihood_omhn.cpu_score(omega_theta: ndarray, mutation_data: StateContainer) float#
Computes the log-likelihood score on the CPU.
- Parameters:
omega_theta (np.ndarray) – Theta matrix for the oMHN (shape: (n+1) x n), where the last row contains observation rates.
mutation_data (StateContainer) – Data used for training.
- Returns:
Log-likelihood score of the given oMHN for the provided data.
- Return type:
float
- mhn.training.likelihood_omhn.cuda_gradient_and_score(omega_theta: ndarray, mutation_data: StateContainer)#
Computes the log-likelihood score and gradient on the GPU.
Note: This function can only be used if the mhn package was compiled with CUDA.
- Parameters:
omega_theta (np.ndarray) – Theta matrix for the oMHN (shape: (n+1) x n), where the last row contains observation rates.
mutation_data (StateContainer) – Data used for training.
- Returns:
The gradient (as a numpy array) and the score (as a float).
- Return type:
tuple[np.ndarray, float]
- mhn.training.likelihood_omhn.gradient_and_score(omega_theta: ndarray, mutation_data: StateContainer) tuple[ndarray, float]#
Computes the log-likelihood score and gradient using both CPU and GPU.
This function uses the CPU implementation for data points with few mutations and CUDA (if available) for data points with many mutations. If CUDA is not installed, the function defaults to CPU.
- Parameters:
omega_theta (np.ndarray) – Theta matrix for the oMHN (shape: (n+1) x n), where the last row contains observation rates.
mutation_data (StateContainer) – Data used for training.
- Returns:
The gradient (as a numpy array) and the score (as a float).
- Return type:
tuple[np.ndarray, float]