From 004a1032976d1146ab6aae7e220594ce039b19bd Mon Sep 17 00:00:00 2001 From: Douglas McLelland Date: Wed, 21 Oct 2026 16:50:01 +0200 Subject: [PATCH] fix(akida2/speech_commands): take the data dir as a flag in the data sanity check The __main__ block of speech_commands_data.py hard-coded a machine-specific dataset path. It now takes -d/--data, defaulting to ./data/speech_commands like the example's other scripts, and moves to the end of the module. Refs HUB-16 Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01DnyD76hgk85WiSBvfGpN6w --- .../speech_commands/speech_commands_data.py | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/akida2/model_zoo/speech_commands/speech_commands_data.py b/akida2/model_zoo/speech_commands/speech_commands_data.py index 94f7e54..a6dfcdf 100644 --- a/akida2/model_zoo/speech_commands/speech_commands_data.py +++ b/akida2/model_zoo/speech_commands/speech_commands_data.py @@ -349,20 +349,6 @@ def get_samples(data_path, data_transform=None, num_samples=1024): return np.array(samples) -# --------------------------------------------------------------------------- -# Sanity check -# --------------------------------------------------------------------------- - -if __name__ == '__main__': - DATA_DIR = '/mnt/data/sc10/' - data_transform = compute_mfcc_range(data_dir=DATA_DIR) - ds_train, ds_test, ds_val = get_datasets( - data_dir=DATA_DIR, batch_size=100, data_transform=data_transform - ) - for features, labels in ds_train.take(1): - print(f"Feature batch shape: {features.shape}, dtype: {features.dtype}") - print(f"Label batch shape: {labels.shape}") - # --------------------------------------------------------------------------- # Public data entry point # --------------------------------------------------------------------------- @@ -382,3 +368,26 @@ def get_data(data_path, batch_size=100, data_transform=None, seed=42, **kwargs): aug_seed=seed, **kwargs, ) + + +# --------------------------------------------------------------------------- +# Sanity check +# --------------------------------------------------------------------------- + +if __name__ == '__main__': + import argparse + + parser = argparse.ArgumentParser( + description='Load one batch of Speech Commands MFCC features and ' + 'print its shape') + parser.add_argument('-d', '--data', default='./data/speech_commands', + help='TFDS data directory holding speech_commands') + args = parser.parse_args() + + data_transform = compute_mfcc_range(data_dir=args.data) + ds_train, ds_test, ds_val = get_datasets( + data_dir=args.data, batch_size=100, data_transform=data_transform + ) + for features, labels in ds_train.take(1): + print(f"Feature batch shape: {features.shape}, dtype: {features.dtype}") + print(f"Label batch shape: {labels.shape}")