deepsphere.utils package

Submodules

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.

Parameters:
  • nodes (int) – initial number of nodes.
  • depth (int) – the depth of the UNet.
  • ["combinatorial", "normalized"] (laplacian_type) – 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.laplacian_funcs.prepare_laplacian(laplacian)[source]

Prepare a graph Laplacian to be fed to a graph convolutional layer.

deepsphere.utils.laplacian_funcs.scipy_csr_to_sparse_tensor(csr_mat)[source]

Convert scipy csr to sparse pytorch tensor.

Parameters:csr_mat (csr_matrix) – The sparse scipy matrix.
Returns:The sparse torch matrix.
Return type:sparse_tensor torch.sparse.FloatTensor

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:dict

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

Parameters:nodes (int) – the number of nodes should be a power of 4
Returns:the corresponding bandwidth
Return type:int
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 tensor
  • ratio (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

Parameters:
  • nodes (int) – combined dimensions
  • ratio (float) – ratio between the two dimensions
Returns:

separated dimensions

Return type:

int, int

deepsphere.utils.samplings.healpix_resolution_calculator(nodes)[source]

Calculate the resolution of a healpix graph for a given number of nodes.

Parameters:nodes (int) – number of nodes in healpix sampling
Returns:resolution for the matching healpix graph
Return type:int
deepsphere.utils.samplings.icosahedron_nodes_calculator(order)[source]

Calculate the number of nodes corresponding to the order of an icosahedron graph

Parameters:order (int) – order of an icosahedron graph
Returns:number of nodes in icosahedron sampling for that order
Return type:int
deepsphere.utils.samplings.icosahedron_order_calculator(nodes)[source]

Calculate the order of a icosahedron graph for a given number of nodes.

Parameters:nodes (int) – number of nodes in icosahedron sampling
Returns:order for the matching icosahedron graph
Return type:int

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

Module contents