CRF in which each direction of edges has their own set of parameters.
Pairwise potentials are not symmetric and are independend for each kind of edges. This leads to n_classes * n_features parameters for unary potentials and n_edge_types * n_classes ** 2 parameters for edge potentials. The number of edge-types is two for a 4-connected neighborhood (horizontal and vertical) or 4 for a 8 connected neighborhood (additionally two diagonals).
Unary evidence x is given as array of shape (width, height, n_states), 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=”lp”
neighborhood : int, default=4
|
---|
Methods
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[, flat]) | |
get_features(x) | |
get_pairwise_potentials(x, w) | |
get_unary_potentials(x, w) | Computes unary potentials for x and w. |
inference(x, w[, relaxed, return_energy]) | |
loss(y, y_hat) | |
loss_augmented_inference(x, y, w[, relaxed, ...]) | |
max_loss(y) | |
psi(x, y) | Feature vector associated with instance (x, y). |
Computes unary potentials for x and w.
Parameters : | x : tuple
w : ndarray, shape=(size_psi,)
|
---|---|
Returns : | unary : ndarray, shape=(n_states)
|
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 : ndarray, shape (width, height, n_states)
y : ndarray or tuple
|
---|---|
Returns : | p : ndarray, shape (size_psi,)
|