pystruct.models.GridCRF(n_states=None, n_features=None, inference_method=None, neighborhood=4)[source]¶Pairwise CRF on a 2d grid.
Pairwise potentials are symmetric and the same for all edges. This leads to n_classes parameters for unary potentials and n_classes * (n_classes + 1) / 2 parameters for edge potentials.
Unary evidence x is given as array of shape (width, height, n_features),
labels y are given as array of shape (width, height). Grid sizes do not
need to be constant over the dataset.
| Parameters: | n_states : int, default=2 
 inference_method : string, default=”ad3” 
 neighborhood : int, default=4 
 | 
|---|
Methods
| 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]) | |
| initialize(X, Y) | |
| joint_feature(x, y) | Feature vector associated with instance (x, y). | 
| loss(y, y_hat) | |
| loss_augmented_inference(x, y, w[, relaxed, ...]) | |
| max_loss(y) | 
joint_feature(x, y)¶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,) 
 |