From f6a38c5eb01b0a7fa281170203f9bec2dcca1c99 Mon Sep 17 00:00:00 2001 From: appellet Date: Fri, 30 May 2025 02:12:48 +0200 Subject: [PATCH] feat: improve --- README.md | 32 ++++++++------------------------ encoder.py | 4 ++-- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 6502000..3730fe5 100644 --- a/README.md +++ b/README.md @@ -77,36 +77,20 @@ python3 encoder.py "message_40_characters" ```bash python3 channel.py ``` -### 6. Decode the output.tct + +### 6. Decode the output.txt ```bash python3 decoder.py ``` - ---- - -## Manual decoding of server output - -If you want to decode `output.txt` yourself: +### 7. send input.txt to the server and get output.txt ```bash -python3 - << 'EOF' -import numpy as np -import encoder, decoder - -# Load noisy samples -Y = np.loadtxt("output.txt") - -# Rebuild codebook -C = encoder.make_codebook(r=5, num_blocks=40) - -# Decode -msg = decoder.decode_blocks(Y, C) -print("Decoded message:", msg) -EOF +python3 client.py \ + --input_file input.txt \ + --output_file output.txt \ + --hostname iscsrv72.epfl.ch \ + --port 80 ``` ---- - -Feel free to adjust `--trials` or swap between `local` and `server` modes as needed. diff --git a/encoder.py b/encoder.py index b804559..003eb7d 100644 --- a/encoder.py +++ b/encoder.py @@ -5,12 +5,12 @@ ALPHABET = "abcdefghijklmnopqrstuvwxyz" \ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" \ "0123456789 ." -CHAR_TO_IDX = {c: i for i, c in enumerate(ALPHABET)} - G = 10.0 ENERGY_LIMIT = 2000.0 TEXT_LENGTH = 40 ALPHABET_LENGTH = len(ALPHABET) +CHAR_TO_IDX = {c: i for i, c in enumerate(ALPHABET)} + assert ALPHABET_LENGTH == 64