alpine.utils package#
Submodules#
alpine.utils.checkers module#
- alpine.utils.checkers.check_lossfn_types(loss_function)#
- alpine.utils.checkers.check_opt_types(x)#
Check if the optimizer name is a string or a callable. If it is a string, check if it is in the list of supported optimizers. :param x: The optimizer name or callable. Must be a string or a torch.optim object. :type x: str or callable
- alpine.utils.checkers.check_sch_types(x)#
Check if the scheduler is of the right type. :param x: learning rate scheduler, must be a torch.optim.lr_scheduler or partial object. :type x: callable
- alpine.utils.checkers.wrap_signal_instance(x)#
alpine.utils.coords module#
- alpine.utils.coords.get_coords2d(H, W)#
Get 2D coordinates for a grid size H x W.
- Parameters:
H (int) – Height of field / image.
W (int) – Width of field / image.
- Returns:
returns a tensor of shape (H*W, 2) with coordinates ranging from (-1, 1).
- Return type:
torch.Tensor
- alpine.utils.coords.get_coords3d(H, W, D)#
Get 3D coordinates for a grid size H x W x D.
- Parameters:
H (int) – Height of field / image.
W (int) – Width of field / image.
D (int) – Depth of field / image.
- Returns:
returns a tensor of shape (H*W*D, 3) with coordinates ranging from (-1, 1).
- Return type:
torch.Tensor
- alpine.utils.coords.get_coords3d_INT(H, W, D)#
- alpine.utils.coords.get_coords_nd(*args, bounds=(-1, 1), indexing='ij')#
Get flattened coordinates for ND grid.
- Parameters:
bounds (tuple, optional) – Bounds over the coordinates. Defaults to (-1,1).
indexing (str, optional) – Indexing scheme for meshgrid. Defaults to ‘ij’.
- Returns:
Returns a tensor of shape (n, len(args)) with coordinates ranging from (-1, 1).
- Return type:
_type_
- alpine.utils.coords.get_coords_spatial(*args, bounds=(-1, 1), indexing='ij')#
Get spatial coordinates for ND grid.
- Parameters:
bounds (tuple, optional) – Bounds over the coordinates. Defaults to (-1,1).
indexing (str, optional) – Indexing scheme for meshgrid. Defaults to ‘ij’.
- Returns:
Returns a tensor of spatial coordinates across each dimension with coordinates ranging from (-1, 1).
- Return type:
torch.Tensor
alpine.utils.functional module#
- alpine.utils.functional.functional_model_call(model, params, coords)#
- alpine.utils.functional.get_stacked_weights_and_bias_from_statedicts(params, N)#
alpine.utils.volutils module#
- alpine.utils.volutils.march_and_save(occupancy, mcubes_thres, savename, smoothen=False)#
Convert volumetric occupancy cube to a 3D mesh
- Inputs:
occupancy: (H, W, T) occupancy volume with values going from 0 to 1 mcubes_thres: Threshold for marching cubes algorithm savename: DAE file name to save smoothen: If True, the mesh is binarized, smoothened, and then the
marching cubes is applied
- Outputs:
None
Module contents#
- alpine.utils.normalize(x, mode='minmax')#
- alpine.utils.normalize_nd(tensor, dim=None)#