From 1f49043484d59dd118dc1a1d2dc3b08aca49cfe5 Mon Sep 17 00:00:00 2001 From: "haoxiangsnr@gmail.com" Date: Tue, 23 Jan 2024 01:17:10 +0000 Subject: [PATCH] egs: update test dataset configuration --- notebooks/check_metric.ipynb | 144 ++++++++++++++++++ .../spiking_fullsubnet/baseline_m.toml | 6 +- .../spiking_fullsubnet/dataloader.py | 2 + .../intel_ndns/spiking_fullsubnet/trainer.py | 6 + 4 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 notebooks/check_metric.ipynb diff --git a/notebooks/check_metric.ipynb b/notebooks/check_metric.ipynb new file mode 100644 index 0000000..b2dec8d --- /dev/null +++ b/notebooks/check_metric.ipynb @@ -0,0 +1,144 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import numpy as np" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "# Apply profit to the metrics\n", + "def get_polyfit_val(self, sig, bak, ovr, is_personalized_MOS=False):\n", + " if is_personalized_MOS:\n", + " p_ovr = np.poly1d([-0.00533021, 0.005101, 1.18058466, -0.11236046])\n", + " p_sig = np.poly1d([-0.01019296, 0.02751166, 1.19576786, -0.24348726])\n", + " p_bak = np.poly1d([-0.04976499, 0.44276479, -0.1644611, 0.96883132])\n", + " else:\n", + " p_ovr = np.poly1d([-0.06766283, 1.11546468, 0.04602535])\n", + " p_sig = np.poly1d([-0.08397278, 1.22083953, 0.0052439])\n", + " p_bak = np.poly1d([-0.13166888, 1.60915514, -0.39604546])\n", + "\n", + " sig_poly = p_sig(sig)\n", + " bak_poly = p_bak(bak)\n", + " ovr_poly = p_ovr(ovr)\n", + "\n", + " return sig_poly, bak_poly, ovr_poly" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "(3.163024522199478, 3.6073455928302955, 2.750688625478262)\n" + ] + } + ], + "source": [ + "a_lif_metrics = (3.36576, 3.47725, 2.95402)\n", + "a_lif_poly = get_polyfit_val(None, *a_lif_metrics)\n", + "print(a_lif_poly)" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "synops = 419556 * 2\n", + "neuronops = 2762\n", + "buffer_latency = 0.032\n", + "enc_dec_latency = 0.030 / 1000\n", + "dns_latency = 0\n", + "dt = 0.008" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "866732\n", + "Solution Latency : 32.030 ms\n", + "Power proxy (Effective SynOPS) : 108341500.000 ops/s\n", + "PDP proxy (SynOPS-delay product) : 1790.797 ops\n" + ] + } + ], + "source": [ + "latency = buffer_latency + enc_dec_latency + dns_latency\n", + "effective_synops_rate = (synops + 10 * neuronops) / dt\n", + "synops_delay_product = 55.91 * 10**3 * latency\n", + "\n", + "print(synops + 10 * neuronops)\n", + "print(f'Solution Latency : {latency * 1000: .3f} ms')\n", + "print(f'Power proxy (Effective SynOPS) : {effective_synops_rate:.3f} ops/s')\n", + "print(f'PDP proxy (SynOPS-delay product) : {synops_delay_product: .3f} ops')" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Solution Latency : 32.030 ms\n", + "Power proxy (Effective SynOPS) : 108341500.000 ops/s\n", + "PDP proxy (SynOPS-delay product) : 3470178.245 ops\n" + ] + } + ], + "source": [ + "latency = buffer_latency + enc_dec_latency + dns_latency\n", + "effective_synops_rate = (synops + 10 * neuronops) / dt\n", + "synops_delay_product = effective_synops_rate * latency\n", + "\n", + "print(f'Solution Latency : {latency * 1000: .3f} ms')\n", + "print(f'Power proxy (Effective SynOPS) : {effective_synops_rate:.3f} ops/s')\n", + "print(f'PDP proxy (SynOPS-delay product) : {synops_delay_product: .3f} ops')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "audiozen", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.10.11" + }, + "orig_nbformat": 4 + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/recipes/intel_ndns/spiking_fullsubnet/baseline_m.toml b/recipes/intel_ndns/spiking_fullsubnet/baseline_m.toml index aa72739..fdb34e9 100644 --- a/recipes/intel_ndns/spiking_fullsubnet/baseline_m.toml +++ b/recipes/intel_ndns/spiking_fullsubnet/baseline_m.toml @@ -86,8 +86,8 @@ num_workers = 8 [test_dataset] path = "dataloader.DNSAudio" [test_dataset.args] -root = "/datasets/IntelNeuromorphicDNSChallenge-latest/data/MicrosoftDNS_4_ICASSP/test_set_1/" +root = "/nfs/xhao/data/intel_ndns/test_set/" train = false [test_dataset.dataloader] -batch_size = 24 -num_workers = 8 +batch_size = 1 +num_workers = 0 diff --git a/recipes/intel_ndns/spiking_fullsubnet/dataloader.py b/recipes/intel_ndns/spiking_fullsubnet/dataloader.py index f058ab2..4d0f342 100644 --- a/recipes/intel_ndns/spiking_fullsubnet/dataloader.py +++ b/recipes/intel_ndns/spiking_fullsubnet/dataloader.py @@ -27,6 +27,8 @@ def __init__(self, root="./", limit=None, offset=0, sublen=6, train=True) -> Non if limit: self.noisy_files = self.noisy_files[:limit] + print(f"Found {len(self.noisy_files)} files.") + self.file_id_from_name = re.compile(r"fileid_(\d+)") self.snr_from_name = re.compile(r"snr(-?\d+)") self.target_level_from_name = re.compile(r"tl(-?\d+)") diff --git a/recipes/intel_ndns/spiking_fullsubnet/trainer.py b/recipes/intel_ndns/spiking_fullsubnet/trainer.py index a0571cd..7857e95 100644 --- a/recipes/intel_ndns/spiking_fullsubnet/trainer.py +++ b/recipes/intel_ndns/spiking_fullsubnet/trainer.py @@ -99,3 +99,9 @@ def validation_epoch_end(self, outputs, log_to_tensorboard=True): self.writer.add_scalar(f"metrics_{dataloader_idx}/{metric}", value, self.state.epochs_trained) return score + + def test_step(self, batch, batch_idx, dataloader_idx=0): + return self.validation_step(batch, batch_idx, dataloader_idx) + + def test_epoch_end(self, outputs, log_to_tensorboard=True): + return self.test_epoch_end(outputs, log_to_tensorboard=False)