From 7b4da92f80106b0ff2c514508b23a3ec43273824 Mon Sep 17 00:00:00 2001 From: cy <939601402@qq.com> Date: Sun, 20 Oct 2024 15:49:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20function.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- function.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/function.py b/function.py index 92dd805..ec196e8 100644 --- a/function.py +++ b/function.py @@ -146,6 +146,12 @@ if __name__ == "__main__": "00000000000001111111110000000000" "00000000000000000111100000000000" ) + # 对测试数据进行归一化 + test_data_vector = np.array([int(char) for char in test_data]).reshape(1, 1024) + test_data_min = np.min(test_data_vector) + test_data_max = np.max(test_data_vector) + test_data_vector = (test_data_vector - test_data_min) / (test_data_max - test_data_min) + predicted_label = classify( np.array([int(char) for char in test_data]).reshape(1, 1024), train_data,