tfConstrainedGauss.solve_id package
Submodules
tfConstrainedGauss.solve_id.model_id module
- class tfConstrainedGauss.solve_id.model_id.LayerMultPrecCov(*args, **kwargs)
Bases:
tensorflow.python.keras.engine.base_layer.Layer
Layer that multiplies precision by covarinace matrix
- __init__(n: int, non_zero_idx_pairs: List[Tuple[int, int]], non_zero_vals: numpy.array, **kwargs)
Constructor
- Args:
n (int): Size of matrix non_zero_idx_pairs (List[Tuple[int,int]]): List of non-zero index pairs in the matrix non_zero_vals (np.array): Non-zero values in the precision matrix corresponding to non_zero_idx_pairs
- call(inputs)
Call the layer
- Args:
inputs ([type]): Covariance matrix: batch_size x n x n
- Returns:
[type]: Product of precision and covariance matrix: vector of length batch_size
- classmethod constructDiag(n: int, non_zero_idx_pairs: List[Tuple[int, int]], init_diag_val: float = 1.0, **kwargs)
Constructor for a diagonal precision matrix with elements specified
- Args:
n (int): Size of matrix non_zero_idx_pairs (List[Tuple[int,int]]): List of non-zero index pairs in the matrix init_diag_val (float, optional): Value of the diagonal part of precision matrix. Defaults to 1.0.
- Returns:
LayerMultPrecCov: layer
- classmethod from_config(config)
Construct from config
- get_config()
Get config for writing
- property n_non_zero: int
Number of non-zero elements, not counting twice for symmetry!
- Returns:
int: number of non-zero elements, not counting twice for symmetry!
- class tfConstrainedGauss.solve_id.model_id.ModelID(*args, **kwargs)
Bases:
tensorflow.python.keras.engine.training.Model
Model for the Identidy method
- __init__(mult_lyr: tfConstrainedGauss.solve_id.model_id.LayerMultPrecCov, **kwargs)
- call(input_tensor, training=False)
Wrapper to call the mulitplication layer of precision and covariance matrices
- Args:
input_tensor ([type]): Covariance matrix: batch_size x n x n
- Returns:
[type]: Product of precision and covariance matrix: vector of length batch_size
- classmethod from_config(config)
- get_config()
Returns the config of the layer.
A layer config is a Python dictionary (serializable) containing the configuration of a layer. The same layer can be reinstantiated later (without its trained weights) from this configuration.
The config of a layer does not include connectivity information, nor the layer class name. These are handled by Network (one layer of abstraction above).
Note that get_config() does not guarantee to return a fresh copy of dict every time it is called. The callers should make a copy of the returned dict if they want to modify it.
- Returns:
Python dictionary.
tfConstrainedGauss.solve_id.solve_id module
- class tfConstrainedGauss.solve_id.solve_id.InputsID(n: int, non_zero_idx_pairs: List[Tuple[int, int]], target_cov_mat: <built-in function array>, epochs: int = 100, learning_rate: float = 0.01)
Bases:
object
- __init__(n: int, non_zero_idx_pairs: List[Tuple[int, int]], target_cov_mat: numpy.array, epochs: int = 100, learning_rate: float = 0.01) None
- convert_mat_non_zero_to_inv_mat(mat_non_zero: numpy.array) numpy.array
- convert_mat_non_zero_to_inv_mat_non_zero(mat_non_zero: numpy.array) numpy.array
- convert_mat_to_mat_non_zero(mat: numpy.array) numpy.array
- epochs: int = 100
- learning_rate: float = 0.01
- n: int
- property n_non_zero
- non_zero_idx_pairs: List[Tuple[int, int]]
- report()
- target_cov_mat: numpy.array
- class tfConstrainedGauss.solve_id.solve_id.ResultsID(inputs: tfConstrainedGauss.solve_id.solve_id.InputsID, trained_model: tfConstrainedGauss.solve_id.model_id.ModelID, init_prec_mat_non_zero: <built-in function array>, init_cov_mat_reconstructed: <built-in function array>, learned_prec_mat_non_zero: <built-in function array>, learned_cov_mat: <built-in function array>)
Bases:
object
- __init__(inputs: tfConstrainedGauss.solve_id.solve_id.InputsID, trained_model: tfConstrainedGauss.solve_id.model_id.ModelID, init_prec_mat_non_zero: numpy.array, init_cov_mat_reconstructed: numpy.array, learned_prec_mat_non_zero: numpy.array, learned_cov_mat: numpy.array) None
- init_cov_mat_reconstructed: numpy.array
- init_prec_mat_non_zero: numpy.array
- learned_cov_mat: numpy.array
- property learned_prec_mat
- learned_prec_mat_non_zero: numpy.array
- report()
- trained_model: tfConstrainedGauss.solve_id.model_id.ModelID
- tfConstrainedGauss.solve_id.solve_id.solve_id(inputs: tfConstrainedGauss.solve_id.solve_id.InputsID) tfConstrainedGauss.solve_id.solve_id.ResultsID
Solve the identity proble
- Args:
inputs (InputsID): Inputs
- Returns:
ResultsID: Results