CRF with latent states for variables.
This is also called “hidden dynamics CRF”. For each output variable there is an additional variable which can encode additional states and interactions.
Parameters : | n_labels : int
n_featues : int or None (default=None).
n_states_per_label : int or list (default=2)
inference_method : string, default=”lp”
|
---|
Methods
base_loss(y, y_hat) | |
batch_inference(X, w[, relaxed]) | |
batch_loss(Y, Y_hat) | |
batch_loss_augmented_inference(X, Y, w[, ...]) | |
batch_psi(X, Y[, Y_true]) | |
continuous_loss(y, y_hat) | |
get_edges(x) | |
get_features(x) | |
get_pairwise_potentials(x, w) | Computes pairwise potentials for x and w. |
get_unary_potentials(x, w) | Computes unary potentials for x and w. |
inference(x, w[, relaxed, return_energy]) | Inference for x using parameters w. |
init_latent(X, Y) | |
label_from_latent(h) | |
latent(x, y, w) | |
loss(h, h_hat) | |
loss_augmented_inference(x, h, w[, relaxed, ...]) | |
max_loss(y) | |
psi(x, y) | Feature vector associated with instance (x, y). |
Computes pairwise potentials for x and w.
Parameters : | x : tuple
w : ndarray, shape=(size_psi,)
|
---|---|
Returns : | pairwise : ndarray, shape=(n_states, n_states)
|
Computes unary potentials for x and w.
Parameters : | x : tuple
w : ndarray, shape=(size_psi,)
|
---|---|
Returns : | unary : ndarray, shape=(n_states)
|
Inference for x using parameters w.
Finds (approximately) armin_y np.dot(w, psi(x, y)) using self.inference_method.
Parameters : | x : tuple
w : ndarray, shape=(size_psi,)
relaxed : bool, default=False
return_energy : bool, default=False
|
---|---|
Returns : | y_pred : ndarray or tuple
|
Feature vector associated with instance (x, y).
Feature representation psi, such that the energy of the configuration (x, y) and a weight vector w is given by np.dot(w, psi(x, y)).
Parameters : | x : tuple
y : ndarray or tuple
|
---|---|
Returns : | p : ndarray, shape (size_psi,)
|