该多层感知机网络的输入特征有风速,吃水,舵角等多项传感器数据,输出只有油耗预测一项。
本人使用TensorFlow构建模型的代码如下:
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.model_selection import train_test_split
import tensorflow as tf
from keras.callbacks import EarlyStopping, ModelCheckpoint
ENV = pd.read_csv(r"C:\Users\14013\Desktop\数据预处理\大表\datas15one.csv")
features = ENV.iloc[:,[6,7,8,9,11,13,14,15]]
target= ENV.iloc[:,[0]]
features_train,features_test, target_train, target_test =train_test_split(features,target,test_size=0.2)
model = tf.keras.Sequential([tf.keras.layers.Dense(8,input_shape=(8,)),
tf.keras.layers.Dense(32,activation='tanh'),
tf.keras.layers.Dense(32,activation='tanh'),
tf.keras.layers.Dense(1)])
model.compile(optimizer = 'adam',
loss = 'mse' # 均方误差
)
callbacks = [EarlyStopping(monitor="val_loss",patience=20,min_delta=0,verbose=2,mode="min"),
ModelCheckpoint(filepath="best_model.h5",monitor="val_loss",save_best_only=True)]
history=model.fit(features_train,target_train,
epochs=15000,
verbose=1,
callbacks =callbacks,
validation_data=(features_test,target_test))
如何从模型结构和训练方法上改良这个感知机模型?(本科生毕设导师要求有创新性,苦啊!)
注:改良方法里不包括:正则化,提前停止,dropout,单纯改感知机内参数的方法。
PS:本人这个毕设感知机网络做的手足无措,若有贵人相助,必重金酬谢。若有意,请在CSDN上请联系我。