Precomposed Modules#
For convenience, we provide some “precomposed” modules which may be useful for simple imaging or modeling applications. In general, though, we encourage you to compose your own set of layers if your application requires it. The source code for a precomposed network can provide useful a starting point. We also recommend checking out the PyTorch documentation on modules.
- class mpol.precomposed.GriddedNet(coords: GridCoords, nchan: int = 1, base_cube: Tensor | None = None)[source]#
Note
This module is provided as a starting point. However, we recommend that you don’t get too comfortable using it and instead write your own (custom) modules following PyTorch idioms, potentially using the source of this routine as a reference point. Using the torch module system directly is much more powerful and expressive.
A basic but functional network for RML imaging. Designed to optimize a model image using the entirety of the dataset in a
mpol.datasets.GriddedDataset(i.e., gradient descent). For stochastic gradient descent (SGD), where the model is only seeing a fraction of the dataset with each iteration, we recommend defining your own module in your analysis code, following the ‘Getting Started’ guide.graph TD subgraph GriddedNet bc(BaseCube) --> HannConvCube HannConvCube --> ImageCube ImageCube --> FourierLayer end FourierLayer --> il([Loss]) ad[[Dataset]] --> il([Loss])- Parameters:
coords (
mpol.coordinates.GridCoords)nchan (int) – the number of channels in the base cube. Default = 1.
base_cube (
mpol.images.BaseCubeorNone) – a pre-packed base cube to initialize the model with. If None, assumestorch.zeros.
After the object is initialized, instance variables can be accessed, for example
- Variables:
bcube – the
BaseCubeinstanceicube – the
ImageCubeinstancefcube – the
FourierCubeinstance
For example, you’ll likely want to access the
self.icube.sky_modelat some point.- forward() Tensor[source]#
Feed forward to calculate the model visibilities. In this step, a
BaseCubeis fed to aHannConvCubeis fed to aImageCubeis fed to aFourierCubeto produce the visibility cube.- Return type:
1D complex torch tensor of model visibilities.
- predict_loose_visibilities(uu: Tensor, vv: Tensor) Tensor[source]#
Use the
mpol.fourier.NuFFTto calculate loose model visibilities from the cube stored toself.icube.packed_cube.- Parameters:
uu (
torch.Tensorof class:`torch.double) – array of u spatial frequency coordinates, not including Hermitian pairs. Units of [\(\mathrm{k}\lambda\)]vv (
torch.Tensorof class:`torch.double) – array of v spatial frequency coordinates, not including Hermitian pairs. Units of [\(\mathrm{k}\lambda\)]
- Returns:
:class:`torch.Tensor` of `class – model visibilities corresponding to
uuandvvlocations.- Return type:
torch.complex128