open3d.ml.tf.ops.trilinear_devoxelize¶
-
open3d.ml.tf.ops.
trilinear_devoxelize
(coords, features, resolution, is_training, name=None)¶ Trilinear Devoxelize.
This function takes a 3D voxel grid and a list of coordinates and computes interpolated features corresponding to each point.
- Minimal example::
import open3d.ml.tf as ml3d
- coords = tf.Tensor(
- [[[0.2 0.0 0.0 1.0 1.5]
[1.0 1.2 0.9 0.0 0.7] [0.2 0.6 0.8 0.7 1.1]]], shape=(1, 3, 5), dtype=float32)
features = tf.Tensor( [[[[[0. 0.5]
[0.6 0.4]]
- [[0.5 0.7]
[0.6 0.5]]]
- [[[0.4 0.8]
[0.6 0.3]]
- [[0.4 0.2]
[0.8 0.6]]]
- [[[0.1 0.2]
[0. 0.6]]
- [[0.9 0. ]
[0.2 0.3]]]]], shape=(1, 3, 2, 2, 2), dtype=float32)
- ml3d.ops.trilinear_devoxelize(coords,
features, resolution, is_training)
# returns output tf.Tensor( # array([[[0.564 , 0.508 , 0.436 , 0.64 , 0.5005 ], # [0.58400005, 0.39200002, 0.396 , 0.26000002, 0.47900003], # [0.14 , 0.36 , 0.45000002, 0.27 , 0.0975 ]]], # shape=(1, 3, 5), dtype=float32) # # indices tf.Tensor([[[ 2, 2, 0, 4, 5], # [ 3, 3, 1, 5, 6], # [ 2, 4, 2, 4, 7], # [ 3, 5, 3, 5, 8], # [ 6, 2, 0, 4, 9], # [ 7, 3, 1, 5, 10], # [ 6, 4, 2, 4, 11], # [ 7, 5, 3, 5, 12]]], # shape=(1, 8, 5), dtype=float32) # # weights tf.Tensor([[[0.64000005, 0.31999996, 0.02 , 0.3 , 0.135 ], # [0.16000001, 0.48 , 0.08000002, 0.7 , 0.015 ], # [0. , 0.08000001, 0.17999998, 0. , 0.315 ], # [0. , 0.12000003, 0.71999997, 0. , 0.03500001], # [0.16000001, 0. , 0. , 0. , 0.135 ], # [0.04 , 0. , 0. , 0. , 0.015 ], # [0. , 0. , 0. , 0. , 0.315 ], # [0. , 0. , 0. , 0. , 0.03500001]]], # shape=(1, 8, 5), dtype=float32)
- Parameters
coords – A Tensor of type float32. List of 3D coordinates for which features to be interpolated. The shape of this tensor is [B, 3, N]. The range of coordinates is [0, resolution-1]. If all of the adjacent position of any coordinate are out of range, then the interpolated features will be 0. Voxel centers are at integral values of voxel grid.
features – A Tensor of type float32. A voxel grid of shape [B, C, R, R, R]. Here R is resolution.
resolution – An int. Integer attribute defining resolution of the voxel grid.
is_training – A bool. Boolean variable for training phase.
name – A name for the operation (optional).
- Returns
A tuple of Tensor objects (outputs, indices, weights).
outputs: A Tensor of type float32. Features for each point. The shape of this tensor is [B, C, N]. indices: A Tensor of type int32. Indices which are used to interpolate features. Shape is [B, 8, N]. weights: A Tensor of type float32. Weights for each index used to interpolate features. Shape is [B, 8, N].