From ec9794d8863a7b5a980652b57c5331060f76ce00 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sat, 25 May 2024 20:43:45 +0200 Subject: [PATCH] README and bugfixes --- README.md | 7 +++++++ config.yaml | 2 +- main.py | 9 +++++---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fa7ad32..03d8d96 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,13 @@ By accurately predicting the next timestep, the delta (difference) between the a The neural networks used in this solution are tiny, making it possible to meet the latency and power requirements if implemented more efficiently. +## TODO + +- All currently implemented bitstream encoders are rather naive. We know, that lead values from the N1 only have 10 bit precision, but wav file provides yus with 32bit floats. All my bitstream encoders are also based on 32bit floats, discretizing back into the 10 bit space would be a low hanging fruit for ~3.2x compression. +- Since we merely encode the remaining delta, we can go even more efficient by constructing something along the lines of a huffman tree. +- Loss is not coming down during training... +- Make a logo + ## Installation To install the necessary dependencies, create a virtual environment and install the requirements: diff --git a/config.yaml b/config.yaml index 8568d5d..3c81903 100644 --- a/config.yaml +++ b/config.yaml @@ -63,7 +63,7 @@ training: batch_size: 64 # Batch size for training. num_batches: 16 # Batches per epoch learning_rate: 0.001 # Learning rate for the optimizer. - eval_freq: 8 # Frequency of evaluation during training (in epochs). + eval_freq: -1 # 8 # Frequency of evaluation during training (in epochs). save_path: models # Directory to save the best model and encoder. num_points: 1000 # Number of data points to visualize diff --git a/main.py b/main.py index f7ced92..97b96f9 100644 --- a/main.py +++ b/main.py @@ -190,7 +190,7 @@ class SpikeRunner(Slate_Runner): total_sequences = 0 with torch.no_grad(): - for lead_idx in range(len(self.test_data)): + for lead_idx in range(len(self.test_data[:8])): lead_data = self.test_data[lead_idx] true_data = [] predicted_data = [] @@ -238,10 +238,10 @@ class SpikeRunner(Slate_Runner): for t in range(self.input_size): target = torch.tensor(targets[i]) true_data.append(target.cpu().numpy()) - predicted_data.append(predictions[i, t, :].cpu().numpy()) - delta_data.append((target - predictions[i, t, :]).cpu().numpy()) + predicted_data.append(predictions[i].cpu().numpy()) + delta_data.append((target - predictions[i]).cpu().numpy()) - loss = self.criterion(predictions[i, t, :], target) + loss = self.criterion(predictions[i].cpu(), target) total_loss += loss.item() # Append true and predicted data for this lead sequence @@ -283,6 +283,7 @@ class SpikeRunner(Slate_Runner): def save_models(self, epoch): + return print('Saving models...') torch.save(self.projector.state_dict(), os.path.join(self.save_path, f"best_projector_epoch_{epoch+1}.pt")) torch.save(self.middle_out.state_dict(), os.path.join(self.save_path, f"best_middle_out_epoch_{epoch+1}.pt"))