Skip to content

Instantly share code, notes, and snippets.

@taiya
Created August 27, 2021 23:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taiya/4be7f9201a7363e5e59db85b71e94529 to your computer and use it in GitHub Desktop.
Save taiya/4be7f9201a7363e5e59db85b71e94529 to your computer and use it in GitHub Desktop.
mock tf.data.Dataset
def get_dataset_mock(num_examples=1, num_classes=40):
output_types = {'points': tf.float32, 'label': tf.int64}
output_shapes = {'points': (2048, 3), 'label': (1,)}
def generator():
for i in range(num_examples):
yield {
'points':
tf.random.uniform(
output_shapes['points'],
dtype=output_types['points']),
'label':
tf.random.uniform(
output_shapes['label'],
dtype=output_types['label'],
maxval=num_classes),
}
dataset = tf.data.Dataset.from_generator(
generator,
output_types=output_types,
output_shapes=output_shapes,
)
ds_train = tfds.as_numpy(dataset)
ds_test = tfds.as_numpy(dataset)
return ds_train, ds_test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment