VL_NNPDIST - CNN p-distance from target.

VL_NNPDIST(X, X0, P) computes the P distance raised of each feature vector in X to the corresponding feature vector in X0:

  Y(i,j,1) = (SUM_d (X(i,j,d) - X0(i,j,d))^P)^(1/P)

X0 should have the same size as X; the outoput Y has the same height and width as X, but depth equal to 1. Optionally, X0 can be a 1 x 1 x D x N array, in which case the same target feature vector in X0 is compared to all feature vectors in X. In that case, however, the DZDX0 are of size of X.

Setting the noRoot option to true does not take the 1/P power in the formula, computing instead

  Y(i,j,1) = SUM_d (X(i,j,d) - X0(i,j,d))^P

For example, vl_nnpdist(x, x0, 2, 'noRoot', true) computes the squared L2 distance.

[DZDX, DZDX0] = VL_NNPDISTP(X, X0, P, DZDY) computes the derivative of the block inputs projected onto DZDY. DZDX, DZDX0 and DZDY have the same dimensions as X and Y, respectively.

VL_NNPDIST(___, 'OPT', VAL, ...) accepts the following options: