deepsphere.utils package¶
Submodules¶
deepsphere.utils.initialization module¶
Initializing device
-
deepsphere.utils.initialization.
init_dataset_temp
(parser, indices, transform_image, transform_labels)[source]¶ Initialize the dataset
- Parameters
- Returns
the dataset
- Return type
dataset
-
deepsphere.utils.initialization.
init_device
(device, unet)[source]¶ Initialize device based on cpu/gpu and number of gpu
- Parameters
- Raises
Exception – There is an error in configuring the cpu or gpu
- Returns
the model placed on device, the device
- Return type
torch.Module, torch.device
deepsphere.utils.laplacian_funcs module¶
Functions related to getting the laplacian and the right number of pixels after pooling/unpooling.
-
deepsphere.utils.laplacian_funcs.
get_equiangular_laplacians
(nodes, depth, ratio, laplacian_type)[source]¶ Get the equiangular laplacian list for a certain depth. :param nodes: initial number of nodes. :type nodes: int :param depth: the depth of the UNet. :type depth: int :param laplacian_type [“combinatorial”, “normalized”]: the type of the laplacian.
- Returns
increasing list of laplacians
- Return type
laps (list)
-
deepsphere.utils.laplacian_funcs.
get_healpix_laplacians
(nodes, depth, laplacian_type)[source]¶ Get the healpix laplacian list for a certain depth. :param nodes: initial number of nodes. :type nodes: int :param depth: the depth of the UNet. :type depth: int :param laplacian_type [“combinatorial”, “normalized”]: the type of the laplacian.
- Returns
increasing list of laplacians.
- Return type
laps (list)
-
deepsphere.utils.laplacian_funcs.
get_icosahedron_laplacians
(nodes, depth, laplacian_type)[source]¶ Get the icosahedron laplacian list for a certain depth. :param nodes: initial number of nodes. :type nodes: int :param depth: the depth of the UNet. :type depth: int :param laplacian_type [“combinatorial”, “normalized”]: the type of the laplacian.
- Returns
increasing list of laplacians.
- Return type
laps (list)
deepsphere.utils.parser module¶
Command Line Parser realated functions. One function creates the parser. Another function allows hybird usage of: - a yaml file with predefined parameters and - user inputted parameters through the command line.
-
deepsphere.utils.parser.
create_parser
()[source]¶ Creates a parser with all the variables that can be edited by the user.
- Returns
a parser for the command line
- Return type
parser
-
deepsphere.utils.parser.
parse_config
(parser)[source]¶ Takes the yaml file given through the command line Adds all the yaml file parameters, unless they have already been defined in the command line. Checks all values have been set else raises a Value error. :param parser: parser to be updated by the yaml file parameters :type parser: argparse.parser
- Raises
ValueError – All fields must be set in the yaml config file or in the command line. Raises error if value is None (was not set).
- Returns
parsed args of the parser
- Return type
deepsphere.utils.samplings module¶
Different samplings require various calculations. The calculations present here are for equiangular, healpix, icosahedron samplings.
-
deepsphere.utils.samplings.
equiangular_bandwidth
(nodes)[source]¶ Calculate the equiangular bandwidth based on input nodes
-
deepsphere.utils.samplings.
equiangular_calculator
(tensor, ratio)[source]¶ From a 3D input tensor and a known ratio between the latitude dimension and longitude dimension of the data, reformat the 3D input into a 4D output while also obtaining the bandwidth.
- Parameters
tensor (
torch.tensor
) – 3D input tensorratio (float) – the ratio between the latitude and longitude dimension of the data
- Returns
4D tensor, the bandwidths for lat. and long.
- Return type
torch.tensor
, int, int
-
deepsphere.utils.samplings.
equiangular_dimension_unpack
(nodes, ratio)[source]¶ Calculate the two underlying dimensions from the total number of nodes
-
deepsphere.utils.samplings.
healpix_resolution_calculator
(nodes)[source]¶ Calculate the resolution of a healpix graph for a given number of nodes.
deepsphere.utils.stats_extractor module¶
Get Means and Standard deviations for all features of a dataset.
-
deepsphere.utils.stats_extractor.
stats_extractor
(dataset)[source]¶ Iterates over a dataset object It is iterated over so as to calculate the mean and standard deviation.
- Parameters
dataset (
torch.utils.data.dataloader
) – dataset object to iterate over- Returns
obj:numpy.array, :obj:numpy.array : computed means and standard deviation