automata4cps.denta¶
The module implements the novel DENTA algorithm for the learning of hybrid automata from data.
Author: Nemanja Hranisavljevic, hranisan@hsu-hh.de, nemanja@ai4cps.com
- class automata4cps.denta.DENTA(num_signals, num_hidden_units, first_hidden_size=None, sigma=1.0, sigma_learnable=False, sparsity_weight=0.01, persistence=True, num_hidden_layers=1, window_size=1, window_step=1, sparsity_target=0.1, use_derivatives=0, device='cpu', log_mlflow=False)¶
Bases:
Module
,Automaton
- anomaly_detection(s)¶
- anomaly_score(s)¶
- binary_vector_to_mode(h)¶
- calculate_ad_threshold(d, quantile=0.95)¶
- compute_purity(class_assignments)¶
Computes the purity between cluster and class assignments. Compare to https://nlp.stanford.edu/IR-book/html/htmledition/evaluation-of-clustering-1.html
- Parameters:
cluster_assignments (list) – List of cluster assignments for every point.
class_assignments (list) – List of class assignments for every point.
- Returns:
The purity value.
- Return type:
float
- contrastive_divergence(v0, h0, vk, hk)¶
- decode(h, x_level=0, h_level=None)¶
- dsm_loss(x, v, sigma=0.1)¶
DSM loss from A Connection Between Score Matching
and Denoising Autoencoders
The loss is computed as x_ = x + v # noisy samples s = -dE(x_)/dx_ loss = 1/2*||s + (x-x_)/sigma^2||^2 :param x: input samples :type x: torch.Tensor :param v: sampled noises :type v: torch.Tensor :param sigma: noise scale. Defaults to 0.1. :type sigma: float, optional
- Returns:
DSM loss
- encode(x, rounding=False, x_level=0, h_level=None)¶
- encode_nominal(x, columns=None)¶
- encode_ordinal(x, columns, order=None)¶
- energy(x, h)¶
- find_optimal_threshold_for_f1(data, search_every=1, plot=False)¶
- forward(x)¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- free_energy(x, level=1)¶
- generate(num_examples, num_steps=10)¶
- get_auroc(data)¶
- gmm_model()¶
- learn_denta_network(train_data, valid_data, max_epoch=10, min_epoch=0, weight_decay=0.0, batch_size=128, shuffle=True, verbose=True, early_stopping=False, early_stopping_patience=3, round_latent_during_learning=False)¶
- learn_latent_automaton(train_data, valid_data)¶
- mse(x, r, per_point=False)¶
- num_h()¶
- num_x()¶
- plot_activation_probabilities(d, prepare_data=True)¶
- plot_discretization(time, target, prediction, data=None, data_time=None)¶
- plot_error_histogram(d, v=None)¶
- plot_frequency_of_latent_combinations(d, prepare_data=True)¶
- plot_input_space(data=None, samples=None, show_gaussian_components=False, data_limit=10000, xmin=None, xmax=None, ymin=None, ymax=None, figure_width=600, figure_height=600, show_axis_titles=True, show_energy_contours=False, showlegend=True, show_recon_error_contours=False, ncontours=None, plot_code_positions=True, show_recon_error_heatmap=False, plot_bias_vector=False, show_reconstructions=False, **kwargs)¶
- plot_learning_curve()¶
- predict_discrete_mode(data, prepare_data=True)¶
- prepare_data(x, update_mean_std=False)¶
- pretrain_dbn(train_data, valid_data, **kwargs)¶
- recon(v, round=False, x_level=0, h_level=None)¶
- recon_error(data, input=None, per_point=False, round=False)¶
- sample_h(h)¶
- sample_x(x)¶
- score(x, sigma=None)¶
- sparsity(activations, per_point=False)¶
- sparsity_loss(activations)¶
- train_rbm(train_data, valid_data, level=1, learning_rule='cd', min_epoch=0, max_epoch=10, weight_decay=0.0, batch_size=128, shuffle=True, num_k=1, verbose=True, early_stopping=False, early_stopping_patience=3, use_probability_last_x_update=False)¶
- class automata4cps.denta.LinearRegression(input_dim, output_dim)¶
Bases:
Module
- forward(x)¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Module
instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- train_model(X, y, num_epochs=1000, lr=0.01)¶