DifferentiableR2LogRRBF¶
-
class
menpofit.transform.
DifferentiableR2LogRRBF
(c)[source]¶ Bases:
R2LogRRBF
,DL
Calculates the \(r^2 \log{r}\) basis function.
The derivative of this function is \(r (1 + 2 \log{r})\), where \(r = \lVert x - c \rVert\).
It can compute its own derivative with respect to landmark changes.
-
apply
(x, batch_size=None, **kwargs)¶ Applies this transform to
x
.If
x
is Transformable,x
will be handed this transform object to transform itself non-destructively (a transformed copy of the object will be returned).If not,
x
is assumed to be an ndarray. The transformation will be non-destructive, returning the transformed version.Any
kwargs
will be passed to the specific transform_apply()
method.- Parameters
x (Transformable or
(n_points, n_dims)
ndarray) – The array or object to be transformed.batch_size (int, optional) – If not
None
, this determines how many items from the numpy array will be passed through the transform at a time. This is useful for operations that require large intermediate matrices to be computed.kwargs (dict) – Passed through to
_apply()
.
- Returns
transformed (
type(x)
) – The transformed object or array
-
apply_inplace
(*args, **kwargs)¶ Deprecated as public supported API, use the non-mutating apply() instead.
For internal performance-specific uses, see _apply_inplace().
-
compose_after
(transform)¶ Returns a TransformChain that represents this transform composed after the given transform:
c = a.compose_after(b) c.apply(p) == a.apply(b.apply(p))
a
andb
are left unchanged.This corresponds to the usual mathematical formalism for the compose operator, o.
- Parameters
transform (Transform) – Transform to be applied before self
- Returns
transform (TransformChain) – The resulting transform chain.
-
compose_before
(transform)¶ Returns a TransformChain that represents this transform composed before the given transform:
c = a.compose_before(b) c.apply(p) == b.apply(a.apply(p))
a
andb
are left unchanged.- Parameters
transform (Transform) – Transform to be applied after self
- Returns
transform (TransformChain) – The resulting transform chain.
-
copy
()¶ Generate an efficient copy of this object.
Note that Numpy arrays and other Copyable objects on
self
will be deeply copied. Dictionaries and sets will be shallow copied, and everything else will be assigned (no copy will be made).Classes that store state other than numpy arrays and immutable types should overwrite this method to ensure all state is copied.
- Returns
type(self)
– A copy of this object
-
d_dl
(points)[source]¶ The derivative of the basis function wrt the coordinate system evaluated at points. Let points be \(x\), then \((x - c)^T (1 + 2\log{r_{x, l}})\), where \(r_{x, l} = \| x - c \|\).
- Parameters
points (
(n_points, n_dims)
ndarray) – The spatial points at which the derivative should be evaluated.- Returns
d_dl (
(n_points, n_centres, n_dims)
ndarray) – The Jacobian wrt landmark changes.
-
property
n_centres
¶ The number of centres.
- Type
int
-
property
n_dims
¶ The RBF can only be applied on points with the same dimensionality as the centres.
- Type
int
-
property
n_dims_output
¶ The result of the transform has a dimension (weight) for every centre.
- Type
int
-