deepsphere.layers.samplings package¶
Submodules¶
deepsphere.layers.samplings.equiangular_pool_unpool module¶
EquiAngular Sampling’s Pooling and Unpooling. The pooling goes down two bandwidths at a time. This represents (in the term of classic pooling kernel sizes) a division (pooling) or multiplication (unpooling) of the number of pixels by 4. The kernel size for all modules is henced fixed.
Equiangular sampling theory from: FFTs for the 2-Sphere:Improvements and Variations by Healy (doi=10.1.1.51.5335)
Bandwidth : int or list or tuple. Hence we have a symetric or asymetric sampling. It corresponds to the resolution of the sampling scheme. \(pixels = (2*bw)^{2}\) Allowed number of pixels:
(bw=1) 4 pixels,
(bw=2) 16 pixels,
(bw=3) 36 pixels,
(bw=4) 64 pixels,
(bw=5) 100 pixels.
If latitude bandwidth is different from longitude bandwidth then we have: \(pixels = ((2*bw_{latitude})**2)*((2*bw_{longitude})**2)\)
-
class
deepsphere.layers.samplings.equiangular_pool_unpool.
Equiangular
(ratio=1, mode='average')[source]¶ Bases:
object
Equiangular class, which groups together the corresponding pooling and unpooling.
-
property
pooling
¶ Getter for the pooling class
-
property
unpooling
¶ Getter for the unpooling class
-
property
-
class
deepsphere.layers.samplings.equiangular_pool_unpool.
EquiangularAvgPool
(ratio)[source]¶ Bases:
torch.nn.AvgPool1d
EquiAngular Average Pooling using Average Pooling 1d from pytorch
-
forward
(x)[source]¶ calls Avgpool1d
- Parameters
x (
torch.tensor
) – batch x pixels x features- Returns
torch.tensor
– batch x pooled pixels x features
-
-
class
deepsphere.layers.samplings.equiangular_pool_unpool.
EquiangularAvgUnpool
(ratio)[source]¶ Bases:
torch.nn.Module
EquiAngular Average Unpooling version 1 using the interpolate function when unpooling
-
forward
(x)[source]¶ calls pytorch’s interpolate function to create the values while unpooling based on the nearby values :param x: batch x pixels x features :type x:
torch.tensor
- Returns
batch x unpooled pixels x features
- Return type
-
-
class
deepsphere.layers.samplings.equiangular_pool_unpool.
EquiangularMaxPool
(ratio, return_indices=False)[source]¶ Bases:
torch.nn.MaxPool1d
EquiAngular Maxpooling module using MaxPool 1d from torch
-
forward
(x)[source]¶ calls Maxpool1d and if desired, keeps indices of the pixels pooled to unpool them
- Parameters
input (
torch.tensor
) – batch x pixels x features- Returns
batch x pooled pixels x features and the indices of the pixels pooled
- Return type
tuple(
torch.tensor
, list(int))
-
-
class
deepsphere.layers.samplings.equiangular_pool_unpool.
EquiangularMaxUnpool
(ratio)[source]¶ Bases:
torch.nn.MaxUnpool1d
Equiangular Maxunpooling using the MaxUnpool1d of pytorch
-
forward
(x, indices)[source]¶ calls MaxUnpool1d using the indices returned previously by EquiAngMaxPool
- Parameters
x (
torch.tensor
) – batch x pixels x featuresindices (int) – indices of pixels equiangular maxpooled previously
- Returns
batch x unpooled pixels x features
- Return type
-
-
deepsphere.layers.samplings.equiangular_pool_unpool.
reformat
(x)[source]¶ Reformat the input from a 4D tensor to a 3D tensor
- Parameters
x (
torch.tensor
) – a 4D tensor- Returns
a 3D tensor
- Return type
deepsphere.layers.samplings.healpix_pool_unpool module¶
Healpix Sampling’s Pooling and Unpooling The pooling divides the number of nsides by 2 each time. This represents (in the term of classic pooling kernel sizes) a division (pooling) or multiplication (unpooling) of the number of pixels by 4. The kernel size for all modules is hence fixed.
Sampling theory from: HEALPix — a Framework for High Resolution Discretization, and Fast Analysis of Data Distributed on the Sphere by Gorski (doi: 10.1086/427976)
Figure 1 for relation number of sides and number of pixels and for unpooling using tile. The area of the pixels are the same hence latitude and longitude of the resolution are the same.
The lowest resolution possible with the HEALPix base partitioning of the sphere surface into 12 equal sized pixels See: https://healpix.jpl.nasa.gov/
\(N_{pixels} = 12 * N_{sides}^2\) Nsides is the number of divisions from the baseline of 12 equal sized pixels
-
class
deepsphere.layers.samplings.healpix_pool_unpool.
Healpix
(mode='average')[source]¶ Bases:
object
Healpix class, which groups together the corresponding pooling and unpooling.
-
property
pooling
¶ Get pooling
-
property
unpooling
¶ Get unpooling
-
property
-
class
deepsphere.layers.samplings.healpix_pool_unpool.
HealpixAvgPool
[source]¶ Bases:
torch.nn.AvgPool1d
Healpix Average pooling module
-
forward
(x)[source]¶ forward call the 1d Averagepooling of pytorch
- Parameters
x (
torch.tensor
) – [batch x pixels x features]- Returns
[batch x pooled pixels x features]
- Return type
-
-
class
deepsphere.layers.samplings.healpix_pool_unpool.
HealpixAvgUnpool
[source]¶ Bases:
torch.nn.Module
Healpix Average Unpooling module
-
forward
(x)[source]¶ forward repeats (here more like a numpy tile for the moment) the incoming tensor
- Parameters
x (
torch.tensor
) – [batch x pixels x features]- Returns
[batch x unpooled pixels x features]
- Return type
-
-
class
deepsphere.layers.samplings.healpix_pool_unpool.
HealpixMaxPool
(return_indices=False)[source]¶ Bases:
torch.nn.MaxPool1d
Healpix Maxpooling module
-
forward
(x)[source]¶ Forward call the 1d Maxpooling of pytorch
- Parameters
x (
torch.tensor
) – [batch x pixels x features]- Returns
[batch x pooled pixels x features] and indices of pooled pixels
- Return type
tuple((
torch.tensor
), indices (int))
-
-
class
deepsphere.layers.samplings.healpix_pool_unpool.
HealpixMaxUnpool
[source]¶ Bases:
torch.nn.MaxUnpool1d
Healpix Maxunpooling using the MaxUnpool1d of pytorch
-
forward
(x, indices)[source]¶ calls MaxUnpool1d using the indices returned previously by HealpixMaxPool
- Parameters
tuple (x (
torch.tensor
) – [batch x pixels x features]indices (int)) – indices of pixels equiangular maxpooled previously
- Returns
[
torch.tensor
] – [batch x unpooled pixels x features]
-
deepsphere.layers.samplings.icosahedron_pool_unpool module¶
Icosahedron Sampling’s Pooling and Unpooling. Each pooling takes down an order in the icosahedron. Each unpooling adds the number of pixels corresponding to the next order.
Icosahedron is a polyhedron with 12 vertices and, 20 faces, where a regular icosahedron is a Platonic solid. All faces are regular (equilateral) triangles. This default Icosahedron can be considered at level 0, meaning that no further subdivision has occurred from the platonic solid. See: https://github.com/maxjiang93/ugscnn/blob/master/meshcnn/mesh.py from Max Jiang
-
class
deepsphere.layers.samplings.icosahedron_pool_unpool.
Icosahedron
[source]¶ Bases:
object
Icosahedron class, which simply groups together the corresponding pooling and unpooling.
-
property
pooling
¶ Get pooling.
-
property
unpooling
¶ Get unpooling.
-
property
-
class
deepsphere.layers.samplings.icosahedron_pool_unpool.
IcosahedronPool
(*args, **kwargs)[source]¶ Bases:
torch.nn.Module
Isocahedron Pooling, consists in keeping only a subset of the original pixels (considering the ordering of an isocahedron sampling method).
-
forward
(x)[source]¶ Forward function calculates the subset of pixels to keep based on input size and the kernel_size.
- Parameters
x (
torch.tensor
) – [batch x pixels x features]- Returns
[batch x pixels pooled x features]
- Return type
-
-
class
deepsphere.layers.samplings.icosahedron_pool_unpool.
IcosahedronUnpool
(*args, **kwargs)[source]¶ Bases:
torch.nn.Module
Isocahedron Unpooling, consists in adding 1 values to match the desired un pooling size
-
forward
(x)[source]¶ Forward calculates the subset of pixels that will result from the unpooling kernel_size and then adds 1 valued pixels to match this size
- Parameters
x (
torch.tensor
) – [batch x pixels x features]- Returns
[batch x pixels unpooled x features]
- Return type
-
Module contents¶
DeepSphere Base Documentation doc