From d7b598e6228f4589c456e92d770788c3518bf5ed Mon Sep 17 00:00:00 2001 From: gulongcheng <474084054@qq.com> Date: Tue, 21 Oct 2025 16:00:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/vcs.xml | 6 +++++ .../FC_ML_Baseline_Data_Handler/Data_Load.py | 14 ++++++++++- .../Data_Handle/param-linux.json | 4 ++++ .../Train/param-linux.json | 23 +++++++++++++++++++ .../FC_ML_Baseline_Train/Train_Proxy_Model.py | 14 ++++++++++- 5 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 .idea/vcs.xml create mode 100644 FC_ML_Baseline/FC_ML_Baseline_Test/Data_Handle/param-linux.json create mode 100644 FC_ML_Baseline/FC_ML_Baseline_Test/Train/param-linux.json diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/FC_ML_Baseline/FC_ML_Baseline_Data_Handler/Data_Load.py b/FC_ML_Baseline/FC_ML_Baseline_Data_Handler/Data_Load.py index bfda1f3..cb9e430 100644 --- a/FC_ML_Baseline/FC_ML_Baseline_Data_Handler/Data_Load.py +++ b/FC_ML_Baseline/FC_ML_Baseline_Data_Handler/Data_Load.py @@ -49,13 +49,25 @@ export const sourceCurveData = { ''' import argparse +import sys +import os + +# 获取当前脚本(Data_Load.py)所在的目录 +current_script_dir = os.path.dirname(__file__) # 结果:/home/app/model/ModelTrainingPython/FC_ML_Baseline/FC_ML_Baseline_Data_Handler + +# 从当前目录回退 2 级,得到项目根目录 ModelTrainingPython +root_path = os.path.abspath(os.path.join(current_script_dir, "..", "..")) + +# 将根目录添加到 Python 搜索路径 +sys.path.append(root_path) + from FC_ML_Data.FC_ML_Data_Load.Data_Load_Excel import get_data_from_csv_feature from FC_ML_Model.Model_Train_Data import TrainData from FC_ML_Tool.Serialization import parse_json_file if __name__ == '__main__': parser = argparse.ArgumentParser(description='导入数据文件参数') - parser.add_argument('--param', default='D:\liyong\project\TVS_ML\FC_ML_Baseline\FC_ML_Baseline_Test\param.json', + parser.add_argument('--param', default=r'D:\liyong\project\TVS_ML\FC_ML_Baseline\FC_ML_Baseline_Test\param.json', help='配置参数文件绝对路径') parser.add_argument('--export', default='source.json', help='导出JSON文件名') diff --git a/FC_ML_Baseline/FC_ML_Baseline_Test/Data_Handle/param-linux.json b/FC_ML_Baseline/FC_ML_Baseline_Test/Data_Handle/param-linux.json new file mode 100644 index 0000000..21264e6 --- /dev/null +++ b/FC_ML_Baseline/FC_ML_Baseline_Test/Data_Handle/param-linux.json @@ -0,0 +1,4 @@ +{ + "files": ["sample1.CSV"], + "path": "/home/app/model/ModelTrainingPython/FC_ML_Baseline/FC_ML_Baseline_Test/Data_Handle/" +} diff --git a/FC_ML_Baseline/FC_ML_Baseline_Test/Train/param-linux.json b/FC_ML_Baseline/FC_ML_Baseline_Test/Train/param-linux.json new file mode 100644 index 0000000..9a0c7d9 --- /dev/null +++ b/FC_ML_Baseline/FC_ML_Baseline_Test/Train/param-linux.json @@ -0,0 +1,23 @@ +{ + "files":["sample1.CSV"], + "path": "/home/app/model/ModelTrainingPython/FC_ML_Baseline/FC_ML_Baseline_Test/Train/", + "algorithmParam": { + "inputSize": 8, + "outputSize": 8, + "algorithm": "多项式拟合", + "activateFun": "sigmod", + "lossFun": "l1", + "optimizeFun": "sgd", + "exportFormat": ".onnx", + "trainingRatio": 80, + "loadSize": 32, + "studyPercent": 0.001, + "stepCounts": 3, + "roundPrint": 11, + "round": 1001, + "preDisposeData": false, + "disposeMethod": "minmax", + "dataNoOrder": false + }, + "algorithm": "基础神经网络NN" +} \ No newline at end of file diff --git a/FC_ML_Baseline/FC_ML_Baseline_Train/Train_Proxy_Model.py b/FC_ML_Baseline/FC_ML_Baseline_Train/Train_Proxy_Model.py index 436182e..69fce10 100644 --- a/FC_ML_Baseline/FC_ML_Baseline_Train/Train_Proxy_Model.py +++ b/FC_ML_Baseline/FC_ML_Baseline_Train/Train_Proxy_Model.py @@ -4,7 +4,7 @@ * 传参:python xxx.py 源文件路径 文件名 /xx/xx/param.json * param.json 包含: * { - * + * files:[xxx.excel,xxx.excel,xxx.excel], * path: '/xx/xx/xx',//源文件路径 * algorithmParam:{ algorithm: '多项式拟合', @@ -35,6 +35,18 @@ */ ''' import argparse +import sys +import os + +# 获取当前脚本(Data_Load.py)所在的目录 +current_script_dir = os.path.dirname(__file__) # 结果:/home/app/model/ModelTrainingPython/FC_ML_Baseline/FC_ML_Baseline_Data_Handler + +# 从当前目录回退 2 级,得到项目根目录 ModelTrainingPython +root_path = os.path.abspath(os.path.join(current_script_dir, "..", "..")) + +# 将根目录添加到 Python 搜索路径 +sys.path.append(root_path) + from locale import normalize import torch