FeatureConnector for voxel grids.

During _generate_examples, the feature connector accepts as input any of:

  • dict: dictionary containing the path to a {.mat} file and the key under which the voxel grid is accessible inside the file. Structure of the dictionary: { 'path': 'path/to/file.mat', 'key': 'foo' }

  • np.ndarray: float32 numpy array of shape [X,Y,Z] representing the voxel grid.


A float32 Tensor with shape [X,Y,Z] containing the voxel occupancies.

dtype Return the dtype (or dict of dtype) of this FeatureConnector.
shape Return the shape (or dict of shape) of this FeatureConnector.



See base class for details.


Decode the feature dict to TF compatible input.

tfexample_data Data or dictionary of data, as read by the tf-example reader. It correspond to the tf.Tensor() (or dict of tf.Tensor()) extracted from the tf.train.Example, matching the info defined in get_serialized_info().

tensor_data Tensor or dictionary of tensor, output of the object


See base class for details.


View source

See base class for details.


View source


Return the shape/dtype of features after encoding (for the adapter).

The FileAdapter then use those information to write data on disk.

This function indicates how this feature is encoded on file internally. The DatasetBuilder are written on disk as tf.train.Example proto.


return {
    'image': tfds.features.TensorInfo(shape=(None,), dtype=tf.uint8),
    'height': tfds.features.TensorInfo(shape=(), dtype=tf.int32),
    'width': tfds.features.TensorInfo(shape=(), dtype=tf.int32),

FeatureConnector which are not containers should return the feature proto directly:

return tfds.features.TensorInfo(shape=(64, 64), tf.uint8)

If not defined, the retuned values are automatically deduced from the get_tensor_info function.

features Either a dict of feature proto object, or a feature proto object


See base class for details.


Restore the feature metadata from disk.

If a dataset is re-loaded and generated files exists on disk, this function will restore the feature metadata from the saved file.

data_dir str, path to the dataset folder to which save the info (ex: ~/datasets/cifar10/1.2.0/)
feature_name str, the name of the feature (from the FeaturesDict key)


Save the feature metadata on disk.

This function is called after the data has been generated (by _download_and_prepare) to save the feature connector info with the generated dataset.

Some dataset/features dynamically compute info during _download_and_prepare. For instance:

  • Labels are loaded from the downloaded data
  • Vocabulary is created from the downloaded data
  • ImageLabelFolder compute the image dtypes/shape from the manual_dir

After the info have been added to the feature, this function allow to save those additional info to be restored the next time the data is loaded.

By default, this function do not save anything, but sub-classes can overwrite the function.

data_dir str, path to the dataset folder to which save the info (ex: ~/datasets/cifar10/1.2.0/)
feature_name str, the name of the feature (from the FeaturesDict key)


View source