pytomography.priors.smoothness
#
Module Contents#
Classes#
Implementation of priors with gradients of the form \(\frac{\partial V}{\partial f_r}=\frac{\beta}{\delta}\sum_{s}w_{r,s}\phi\left(\frac{f_r-f_s}{\delta}\right)\) where \(V\) is from the log-posterior probability \(\ln L (\tilde{f}, f) - \beta V(f)\). |
|
Subclass of SmoothnessPrior where \(\phi(x)=x\) corresponds to a quadratic prior \(V(f)=\frac{1}{4}\sum_{r,s} w_{r,s} \left(\frac{f_r-f_s}{\delta}\right)^2\) |
|
Subclass of SmoothnessPrior where \(\phi(x)=\tanh(x)\) corresponds to the logcosh prior \(V(f)=\sum_{r,s} w_{r,s} \log\cosh\left(\frac{f_r-f_s}{\delta}\right)\) |
- class pytomography.priors.smoothness.SmoothnessPrior(beta, delta, phi, device='cpu')#
Bases:
pytomography.priors.prior.Prior
Implementation of priors with gradients of the form \(\frac{\partial V}{\partial f_r}=\frac{\beta}{\delta}\sum_{s}w_{r,s}\phi\left(\frac{f_r-f_s}{\delta}\right)\) where \(V\) is from the log-posterior probability \(\ln L (\tilde{f}, f) - \beta V(f)\).
- Parameters:
beta (float) – Used to scale the weight of the prior
phi (function) – Function \(\phi\) used in formula above
delta (int, optional) – Parameter \(\delta\) in equation above. Defaults to 1.
device (str, optional) – Pytorch device used for computation. Defaults to ‘cpu’.
- get_kernel()#
Obtains the kernel used to get \(\frac{\partial V}{\partial f_r}\) (this is an array with the same dimensions as the object space image)
- Returns:
Kernel used for convolution (number of output channels equal to number of \(s\)), and array of weights \(w_s\) used in expression for gradient.
- Return type:
(torch.nn.Conv3d, torch.tensor)
- set_kernel(object_meta)#
Sets the kernel using get_kernel and the corresponding object metadata.
- Parameters:
object_meta (_type_) – _description_
- Return type:
None
- forward()#
Computes the prior on self.object
- Returns:
Tensor of shape [batch_size, Lx, Ly, Lz] representing \(\frac{\partial V}{\partial f_r}\)
- Return type:
torch.tensor
- class pytomography.priors.smoothness.QuadraticPrior(beta, delta=1, device='cpu')#
Bases:
SmoothnessPrior
Subclass of SmoothnessPrior where \(\phi(x)=x\) corresponds to a quadratic prior \(V(f)=\frac{1}{4}\sum_{r,s} w_{r,s} \left(\frac{f_r-f_s}{\delta}\right)^2\)
- Parameters:
beta (float) – Used to scale the weight of the prior
delta (int, optional) – Parameter \(\delta\) in equation above. Defaults to 1.
device (str, optional) – Pytorch device used for computation. Defaults to ‘cpu’.
- class pytomography.priors.smoothness.LogCoshPrior(beta, delta=1, device='cpu')#
Bases:
SmoothnessPrior
Subclass of SmoothnessPrior where \(\phi(x)=\tanh(x)\) corresponds to the logcosh prior \(V(f)=\sum_{r,s} w_{r,s} \log\cosh\left(\frac{f_r-f_s}{\delta}\right)\)
- Parameters:
beta (float) – Used to scale the weight of the prior
delta (int, optional) – Parameter \(\delta\) in equation above. Defaults to 1.
device (str, optional) – Pytorch device used for computation. Defaults to ‘cpu’.