src.model.deeplearn.dlrun.hierarchical_sg_pre_processorpp

Classes

HierarchicalSGPreProcessorPP(**kwargs)

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. See ReceptiveFieldHierarchicalSG.

Variables:
__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 DLSparseConcatSequencer consume.

Parameters:

inputs (dict) – Dict with key "X" (a tuple (coordinates, features)) and optional key "y" (per-point reference labels for training).

Returns:

(pyout, yout) if y is given, else just pyout. pyout is 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 (when y is given) is a list of per-RF int32 label arrays of shape (R_{k0},).

The C++ pre-processor populates S, D, U directly, so the sparse-conv layers can run a fused tf.gather + matmul without ever looking at h/hD/hU again.

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 the architecture.Architecture.overwrite_pretrained_model() method.

Parameters:

spec (dict) – The key-word specification containing the model’s arguments.