求大神帮忙看看程序哪里有问题
# 载入FD001数据集file_load = 'd:/python_keras/predict aircraft engineer RUL/Dataset/PM_train_guiyihua.csv'
train_df = pd.read_csv(file_load, encoding='gbk')
# print(train_df)
new_features = ['cycle_norm', 's4', 's11', 's12', 's9', 's7', 's14', 's15',
's21', 's2', 's3', 's20', 'setting1', 's13', 's8', 's17']
x_t = train_df
y_t = train_df['RUL']
# 模型参数设置
# 对模型进行优化(每层神经元数量, 每层丢弃率, 迭代步数, 批次样本数)
d =
neuron =
epochs =
batch_size =
seq_length =
def model_t_c(d, n1, n2):
model = Sequential()
model.add(GRU(n1, input_shape=(1, 16)))
model.add(Dropout(d))
model.add(Dense(n2, activation='sigmoid'))
model.add(Dense(1, activation='linear'))
model.compile(optimizer='rmsprop', loss='mse', metrics='mae')
model.summary()
return model
model_t = model_t_c(0.2, 256, 256)
# 贝叶斯优化
hyperparameters = {"d": Real(0, 1, prior='log-uniform'), "n1":Real(0, 1e4, prior='uniform'), "n2":Real(0, 1e4, prior='uniform')}
Kmodel = KerasClassifier(build_fn=model_t, verbose=1)
bayesian = BayesSearchCV(estimator = Kmodel, search_spaces = hyperparameters, n_iter = 200, cv = 5, random_state=42, n_jobs = -1, scoring='neg_mean_squared_error')
bayesian.fit(x_t, y_t)
print(f'Best parameters: {bayesian.best_params_}')
print(f'Best score: {bayesian.best_score_}')
执行上述代码之后会出现下面的错误,目前没有找到解决方案{:10_247:}
TypeError: can't pickle _thread.RLock objects pickle只能保存python基本类型的对象,如列表,字典。thread.RLock应该是模块中定义的对象,所以不能保存。
页:
[1]