Created
August 27, 2021 23:26
-
-
Save taiya/4be7f9201a7363e5e59db85b71e94529 to your computer and use it in GitHub Desktop.
mock tf.data.Dataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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