#全连接神经网络 模型预测 # data_x是输入,输入的尺寸是(n, 6),n是数据的个数 model.stride = 25 data_x = data[-25:, :] # data_y是输出的预测的结果,输出的矩阵的形状是(n, 4), n是数据的个数 data_y = model.predict_LSTM(data_x) print(data_y) # LSTM 模型预测 # data_x是输入,输入的矩阵形状是(n,stride*6) stride是步长,n是数据的个数 #data_x = [[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6],[1,2,3,4,5,6]] # data_y是输出的预测的结果,输出的矩阵的形状是(4,n), n是数据的个数 #model.stride = 5 data_y = model.predict_Net(data_x) print(type(data_y[0])) ############################################ T_len, H2_len, CH4_len, CO_len = 5,10,5,20 # 训练LSTM & Net for stride in [T_len, H2_len, CH4_len, CO_len]: model.online_train_Net(train_path='./data/data_1.csv',model_path='./newmodels',stride=stride, EPOCH=1000) model.online_train_LSTM(train_path='./data/data_1.csv',model_path='./newmodels',stride=stride, EPOCH=1000) # 测试LSTM & Net,返回的res_Net和res_LSTM的格式一样:[气化温度误差率,H2误差率,CH4误差率,CO误差率,平均耗时] res_Net = model.online_test_Net(test_path='./data/data_1.csv',model_path='./newmodels',stride=5) res_LSTM = model.online_test_LSTM(test_path='./data/data_1.csv',model_path='./newmodels',stride=5) #############################################
from Network import Model from PSO import optimize from InputParam import InputParam import numpy as np import time data = np.loadtxt('./data/data.csv', delimiter=',', skiprows=2)[:, 1:7] model = Model(stride=30) param = InputParam() best_x = [[28.12421607, 14.41792793], [74.20071455, 9.92461491], [58.43944117, 11.0825983], [69.17058085, 10.75863371], [36.35079316, 11.28547075], [57.59862793, 10.92375781], [27.67301199, 14.30238826], [75.87876121, 13.22701089], [100.0, 16.10638031], [100.0, 13.78599625]] best_y = 26.45409999049893 # 调用optimize #best_x, best_y = optimize(20, data, 2, model, param) print('best_x = ', best_x) print('best_y = ', best_y) model.stride = 10 predict_y = model.predict_Net(best_x) print(predict_y)