|
ocssw
V2022
|
Public Member Functions | |
| def | __init__ (self, n_mix=5, hidden=[100] *5, lr=1e-3, l2=1e-3, n_iter=1e4, batch=128, imputations=5, epsilon=1e-3, activation='relu', scalerx=None, scalery=None, model_path='Weights', model_name='MDN', no_load=False, no_save=False, seed=None, verbose=False, debug=False, **kwargs) |
| def | predict (self, X, chunk_size=1e5, return_coefs=False, **kwargs) |
| def | extract_predictions (self, coefs, confidence_interval=None, threshold=None, avg_est=False) |
| def | fit (self, X, Y, output_slices=None, **kwargs) |
| def | build (self) |
| def | loss (self, y, output) |
| def | __call__ (self, inputs) |
| def | get_config (self) |
| def | set_config (self, config, *args, **kwargs) |
| def | update_config (self, config, keys=None) |
| def | save (self) |
| def | load (self) |
| def | get_coefs (self, output) |
Public Attributes | |
| model | |
| config | |
Static Public Attributes | |
| string | distribution = 'MultivariateNormalTriL' |
Detailed Description
Mixture Density Network which handles multi-output, full (symmetric) covariance.
Parameters
----------
n_mix : int, optional (default=5)
Number of mixtures used in the gaussian mixture model.
hidden : list, optional (default=[100, 100, 100, 100, 100])
Number of layers and hidden units per layer in the neural network.
lr : float, optional (default=1e-3)
Learning rate for the model.
l2 : float, optional (default=1e-3)
L2 regularization scale for the model weights.
n_iter : int, optional (default=1e4)
Number of iterations to train the model for
batch : int, optional (default=128)
Size of the minibatches for stochastic optimization.
imputations : int, optional (default=5)
Number of samples used in multiple imputation when handling NaN
target values during training. More samples results in a higher
accuracy for the likelihood estimate, but takes longer and may
result in overfitting. Assumption is that any missing data is
MAR / MCAR, in order to allow a multiple imputation approach.
epsilon : float, optional (default=1e-3)
Normalization constant added to diagonal of the covariance matrix.
activation : str, optional (default=relu)
Activation function applied to hidden layers.
scalerx : transformer, optional (default=IdentityTransformer)
Transformer which has fit, transform, and inverse_transform methods
(i.e. follows the format of sklearn transformers). Scales the x
values prior to training / prediction. Stored along with the saved
model in order to have consistent inputs to the model.
scalery : transformer, optional (default=IdentityTransformer)
Transformer which has fit, transform, and inverse_transform methods
(i.e. follows the format of sklearn transformers). Scales the y
values prior to training, and the output values after prediction.
Stored along with the saved model in order to have consistent
outputs from the model.
model_path : pathlib.Path, optional (default=./Weights)
Folder location to store saved models.
model_name : str, optional (default=MDN)
Name to assign to the model.
no_load : bool, optional (default=False)
If true, train a new model rather than loading a previously
trained one.
no_save : bool, optional (default=False)
If true, do not save the model when training is completed.
seed : int, optional (default=None)
Random seed. If set, ensure consistent output.
verbose : bool, optional (default=False)
If true, print various information while loading / training.
debug : bool, optional (default=False)
If true, use control flow dependencies to determine where NaN
values are entering the model. Model runs slower with this
parameter set to true.
Constructor & Destructor Documentation
◆ __init__()
| def __init__ | ( | self, | |
n_mix = 5, |
|||
hidden = [100]*5, |
|||
lr = 1e-3, |
|||
l2 = 1e-3, |
|||
n_iter = 1e4, |
|||
batch = 128, |
|||
imputations = 5, |
|||
epsilon = 1e-3, |
|||
activation = 'relu', |
|||
scalerx = None, |
|||
scalery = None, |
|||
model_path = 'Weights', |
|||
model_name = 'MDN', |
|||
no_load = False, |
|||
no_save = False, |
|||
seed = None, |
|||
verbose = False, |
|||
debug = False, |
|||
| ** | kwargs | ||
| ) |
Member Function Documentation
◆ __call__()
◆ build()
◆ extract_predictions()
| def extract_predictions | ( | self, | |
| coefs, | |||
confidence_interval = None, |
|||
threshold = None, |
|||
avg_est = False |
|||
| ) |
Function used to extract model predictions from the given set of
coefficients. Users should call the predict() method instead, if
predictions from input data are needed.
confidence_interval : float, optional (default=None)
If a confidence interval value is given, then this function
returns (along with the predictions) the upper and lower
{confidence_interval*100}% confidence bounds around the prediction.
threshold : float, optional (default=None)
If set, the model outputs the maximum prior estimate when the prior
probability is above this threshold; and outputs the average estimate
when below the threshold. Any passed value should be in the range (0, 1],
though the sign of the threshold can be negative in order to switch the
estimates (i.e. negative threshold would output average estimate when prior
is greater than the (absolute) value).
avg_est : bool, optional (default=False)
If true, model outputs the prior probability weighted mean as the
estimate. Otherwise, model outputs the maximum prior estimate.
◆ fit()
◆ get_coefs()
◆ get_config()
◆ load()
◆ loss()
◆ predict()
| def predict | ( | self, | |
| X, | |||
chunk_size = 1e5, |
|||
return_coefs = False, |
|||
| ** | kwargs | ||
| ) |
Top level interface to get predictions for a given dataset, which wraps _predict_chunk
to generate estimates in smaller chunks. See the docstring of extract_predictions() for
a description of other keyword parameters that can be given.
chunk_size : int, optional (default=1e5)
Controls the size of chunks which are estimated by the model. If None is passed,
chunking is not used and the model is given all of the X dataset at once.
return_coefs : bool, optional (default=False)
If True, return the estimated coefficients (prior, mu, sigma) along with the
other requested outputs. Note that rescaling the coefficients using scalerx/y
is left up to the user, as calculations involving sigma must be performed in
the basis learned by the model.
◆ save()
◆ set_config()
◆ update_config()
Member Data Documentation
◆ config
◆ distribution
◆ model
The documentation for this class was generated from the following file:
- /gfs-oceanweb/web/ocssw/ocssw_src/src/aquaverse/MDN/model/MDN.py


