Skip to content

Instantly share code, notes, and snippets.

@doleron
Created April 9, 2023 00:39
Show Gist options
  • Save doleron/a2b0fb8cb7c0bf2c61d7c55e44c01eef to your computer and use it in GitHub Desktop.
Save doleron/a2b0fb8cb7c0bf2c61d7c55e44c01eef to your computer and use it in GitHub Desktop.
training_files = []
training_labels = []
validation_files = []
validation_labels = []
for label in range(CLASSES_SIZE):
indexes = np.where(labels == label)[0]
threshold = len(indexes) * 80 // 100
training_indexes = indexes[0:threshold]
training_files_for_class = [files[i] for i in training_indexes]
training_files.extend(training_files_for_class)
training_labels.extend([label] * len(training_files_for_class))
validation_indexes = indexes[threshold:]
validation_files_for_class = [files[i] for i in validation_indexes]
validation_files.extend(validation_files_for_class)
validation_labels.extend([label] * len(validation_files_for_class))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment