我最近学习了C ++编码,并且正在使用Bjarne Stroustrup的入门书进行学习,并获得了以下代码:
epochs=150
learning_rate = 0.001
decay_rate = learning_rate / epochs
optimiser=keras.optimizers.Nadam(lr=learning_rate,schedule_decay=decay_rate)
def create_model():
model = Sequential()
model.add(Dense(21, input_dim=22, kernel_initializer='normal',activation='relu')) #hidden layer one
model.add(Dropout(0.2))
model.add(Dense(19, activation='relu')) #hidden layer 2
model.add(Dropout(0.2))
model.add(Dense(8, activation='relu')) #output layer
model.compile(loss='mean_squared_error', optimizer=optimiser,metrics=['accuracy'])
return model
np.random.seed(seed)
kfold=KFold(n_splits=5, random_state=seed)
scaler=StandardScaler()
x=StandardScaler().fit_transform(x)
model=KerasRegressor(build_fn=create_model, verbose=0,epochs=150, batch_size=70)
history=model.fit(x,y)
scores=cross_val_score(model, x,y,cv=kfold, scoring='neg_mean_squared_error')
print('scores',scores)
print("Hidden: %.2f%% (%.2f%%)" % (scores.mean(), scores.std()))
我复制了自己:
estimators = []
estimators.append(('standardize', StandardScaler()))
estimators.append(('mlp', KerasRegressor(build_fn=create_model, epochs=150, batch_size=70, verbose=0)))
pipeline = Pipeline(estimators)
pipeline.fit(x,y)
kfold = KFold(n_splits=5, shuffle=True, random_state=seed)
results = cross_val_score(pipeline, x, y, cv=kfold, scoring='neg_mean_squared_error')
print("pipeline: %.2f%% (%.2f%%)" % (results.mean(), results.std()))
但这是问题所在,我无法退出在字典中插入单词的初始循环(我添加的while循环是试图对其进行修复,但它似乎也不起作用)。
谢谢您的时间:)。
答案 0 :(得分:0)
内部for循环将一直运行到pki.privateKeyFromPem(pem);
为$pass
为止,如果继续添加有效的字符串,情况可能并非如此。此外,在包装cin >> word
时不需要多余的内容。您可以执行以下操作,或在必要时添加false
语句。
for-loop