src.model.deeplearn.dlrun.hierarchical_sg_pre_processorpp
Classes
|
- class src.model.deeplearn.dlrun.hierarchical_sg_pre_processorpp.HierarchicalSGPreProcessorPP(**kwargs)
- Author:
Alberto M. Esmoris Pena
Preprocess the input dictionary of X (coordinates), F (features), and y (expected values) so it can be feed to a hierarchical sparse neural network such as sparse convolutional neural network.
See
ReceptiveFieldPreProcessor. SeeReceptiveFieldHierarchicalSG.- Variables:
cell_size (float) – See size of
ReceptiveFieldHierarchicalSG.submanifold_window (
np.ndarray) – See w ofReceptiveFieldHierarchicalSG.downsampling_window (
np.ndarray) – See wD ofReceptiveFieldHierarchicalSG.downsampling_stride (
np.ndarray) – See sD ofReceptiveFieldHierarchicalSG.upsampling_window (
np.ndarray) – See wU ofReceptiveFieldHierarchicalSG.upsampling_stride (
np.ndarray) – See sU ofReceptiveFieldHierarchicalSG.feature_reduce_strategy (str) – The per-cell feature reduction strategy applied at level 0 when encoding the input point-wise features into the active cells of the first sparse grid. Defaults to
"mean". Supported values:"mean","max","min","mode"— matches the strategies implemented byadt::grid::SparseGrid::encodeMatrixin C++.
- __init__(**kwargs)
Initialization/instantiation of a Hierarchical Sparse Grid pre-processor.
- Parameters:
kwargs – The key-word arguments for the Hierarchical Sparse Grid pre-processor.
- __call__(inputs)
Execute the pre-processing logic. Builds the hierarchical sparse-grid receptive fields by calling the C++ extension and returns the 9-element pyout that the SpConv layer stack and
DLSparseConcatSequencerconsume.- Parameters:
inputs (dict) – Dict with key
"X"(a tuple(coordinates, features)) and optional key"y"(per-point reference labels for training).- Returns:
(pyout, yout)ifyis given, else justpyout.pyoutis a 9-element list, one entry per tensor-family, each one a per-RF list:pyout[0]F: features per RF, list of \((1 + R_{k0}) \times n_f\) float32 arrays. Row 0 is the per-RF ground row (zeros).pyout[1]h: per-RF list of per-depth tuples(key, value)for the active-cell-index to sequential row map (kept for callers that need the raw hash-table view of the grid).pyout[2]hD: per-RF / per-depth downsampling hash table (cell index at depth \(t\) -> sequential row at depth \(t + 1\)).pyout[3]hU: per-RF / per-depth upsampling hash table (cell index at depth \(t + 1\) -> sequential row at depth \(t\)).pyout[4]n: per-RF axis-wise partition counts \((n_x, n_y, n_z)\) per depth.pyout[5]A: per-RF support point coordinates (the RF anchor in world frame).pyout[6]S: per-RF / per-depth dense submanifold neighbor table, shape \((1 + R_{kt}) \times (2 w_t + 1)^3\), int32. Row 0 is the per-RF ground row (zeros). Entries are 1-based sequential row indices into the depth-\(t\) feature tensor; entry 0 marks “no neighbor” and gathers the ground row.pyout[7]D: per-RF / per-depth dense downsampling neighbor table, shape \((1 + R_{k(t+1)}) \times w_D^3\), int32. Indices point into depth \(t\)’s row space.pyout[8]U: per-RF / per-depth dense upsampling neighbor table, shape \((1 + R_{kt}) \times w_U^3\), int32. Indices point into depth \(t + 1\)’s row space.
yout(whenyis given) is a list of per-RF int32 label arrays of shape(R_{k0},).The C++ pre-processor populates
S,D,Udirectly, so the sparse-conv layers can run a fusedtf.gather+ matmul without ever looking ath/hD/hUagain.
- reduce_labels(X, y, I=None)
Reduce the given labels \(\pmb{y} in \mathbb{Z}_{\geq 0}^{m}\) to the receptive field labels \(\pmb{y}_{k} \in \mathbb{Z}_{\geq 0}^{R_k}\).
- Parameters:
X (
np.ndarray) – The matrix representing the structure space of the original input point cloud (i.e., NOT a particular receptive field).y (
np.ndarray) – The labels of the original point cloud that must be reduced to the receptive fields.I (None) – Not used by hierarchical sparse grids.
- Returns:
The reduced labels for each receptive field.
- Return type:
list
- static find_cpp_reduce_label_function(X, y)
Determine the C++ function that must be used to reduce the point-wise labels considering the data types of the input.
- Parameters:
X (
np.ndarray) – The matrix representing the structure space of the original input point cloud (i.e., NOT a particular receptive field).y (
np.ndarray) – The labels of the original point cloud that must be reduced to the receptive fields.
- Returns:
The C++ function for label reduction.
- overwrite_pretrained_model(spec)
Assist the
model.Model.overwrite_pretrained_model()method through assisting thearchitecture.Architecture.overwrite_pretrained_model()method.- Parameters:
spec (dict) – The key-word specification containing the model’s arguments.