PERK#
- class torchsim.PERK(acquisition=None, *, n_features=1000, length_scale=None, regularization=1e-5, chunk_size=65536, feature_seed=None, complex_mode='cartesian', normalize=False, stream=False, uncertainty=True)[source]#
Bases:
EstimatorParameter estimation via regression with kernels.
This is the random-Fourier-feature form of PERK [1]. Training accumulates the required covariances in chunks, so memory depends on the feature order rather than the number of simulated training samples. Estimation uses only
cosand matrix multiplication and therefore dispatches to optimized Torch CPU/CUDA kernels without a separate native implementation.- Parameters:
acquisition (Simulator, optional) – The sequence being inverted: a simulator that ships with TorchSim, one written by subclassing
Simulator, or any otherSimulator. Every tissue property that is neither unknown nor measured separately is fixed on it beforehand, with the constructor orbind(). Leave it out to fit from signals handed tofit()directly.n_features (int, optional) – Number of random Fourier features. The default is
1000.length_scale (float or tensor, optional) – Gaussian-kernel length scale for every signal/known-parameter feature.
Noneestimates it from the training standard deviation.regularization (float, optional) – Tikhonov parameter added to the feature covariance. The default is
1e-5.chunk_size (int, optional) – Maximum samples transformed at once. The default is
65536.feature_seed (int, optional) – Seed used for the fixed random feature map. Separate from the seed
fit()draws the training set with.complex_mode ({"cartesian", "magnitude"}, optional) – Representation used for complex signals. Magnitude data are often preferable when image phase is a nuisance parameter.
normalize (bool, optional) – Normalize every signal vector before feature projection. This removes an unknown global scale when it is not itself a target.
stream (bool, optional) – Simulate the training set a chunk at a time and accumulate the covariances as it goes, so memory follows the feature order rather than the number of training samples. The dictionary is never held, and so cannot have a basis estimated from it: a
rankgiven tofit()needs the default. A basis fitted elsewhere, passed tofit()assubspace=, streams perfectly well – each chunk is projected as it is simulated.
Notes
Cartesian complex signals are represented as interleaved real/imaginary features. The learned estimator remains differentiable with respect to its input, which permits its use inside a larger reconstruction network.
References
Methods
fitFit the estimator over a sampling of the tissue it will meet.
from_coefficientsMap coefficients that are already in this estimator's basis.
mapEstimate the tissue a measurement came from.
training_setSimulate a training set: signals, unknowns, and knowns.
uncertainty_ofThe standard deviation the measurement noise leaves on each map.
- property fitted#
Whether training statistics have been fitted.