pystruct.models.
LatentNodeCRF
(n_labels=None, n_features=None, n_hidden_states=2, inference_method=None, class_weight=None, latent_node_features=False)[source]¶CRF with latent variables.
Input x is tuple (features, edges, n_hidden) First features.shape[0] nodes are observed, then n_hidden unobserved nodes.
Currently unobserved nodes don’t have features.
Parameters: | n_labels : int, default=2
n_hidden_states : int, default=2
n_features : int, default=None
inference_method : string, default=None
class_weight : None, or array-like
latent_node_features : bool, default=False
|
---|
Methods
base_loss (y, y_hat) |
|
batch_inference (X, w[, relaxed]) |
|
batch_joint_feature (X, Y[, Y_true]) |
|
batch_loss (Y, Y_hat) |
|
batch_loss_augmented_inference (X, Y, w[, ...]) |
|
continuous_loss (y, y_hat) |
|
inference (x, w[, relaxed, return_energy]) |
Inference for x using parameters w. |
init_latent (X, Y) |
|
initialize (X, Y) |
|
joint_feature (x, y) |
Feature vector associated with instance (x, y). |
label_from_latent (h) |
|
latent (x, y, w) |
|
loss (h, h_hat) |
|
loss_augmented_inference (x, h, w[, relaxed, ...]) |
|
max_loss (h) |
__init__
(n_labels=None, n_features=None, n_hidden_states=2, inference_method=None, class_weight=None, latent_node_features=False)[source]¶inference
(x, w, relaxed=False, return_energy=False)¶Inference for x using parameters w.
Finds (approximately) armin_y np.dot(w, joint_feature(x, y)) using self.inference_method.
Parameters: | x : tuple
w : ndarray, shape=(size_joint_feature,)
relaxed : bool, default=False
return_energy : bool, default=False
|
---|---|
Returns: | y_pred : ndarray or tuple
|
joint_feature
(x, y)[source]¶Feature vector associated with instance (x, y).
Feature representation joint_feature, such that the energy of the configuration (x, y) and a weight vector w is given by np.dot(w, joint_feature(x, y)).
Parameters: | x : tuple
y : ndarray or tuple
|
---|---|
Returns: | p : ndarray, shape (size_joint_feature,)
|