在神经网络中的时代网格搜索:每个参数运行3次(Grid search on epochs in neural network: each parameter being run 3 times)
在进行网格搜索时,我的顺序密集DNN似乎在我的参数网格中贯穿每个参数三次。 我期望它在网格中的每个指定epcohs运行一次:10次,50次和100次。为什么会发生这种情况?
模型架构:
def build_model(): print('building DNN architecture') model = Sequential() model.add(Dropout(0.02, input_shape = (150,))) model.add(Dense(8, init = 'normal', activation = 'relu')) model.add(Dropout(0.02)) model.add(Dense(16, init = 'normal', activation = 'relu')) model.add(Dense(1, init = 'normal')) model.compile(loss = 'mean_squared_error', optimizer = 'adam') print('model succesfully compiled') return model网格搜索时代:
from sklearn.model_selection import GridSearchCV epochs = [10,50,100] param_grid = dict(epochs = epochs) grid = GridSearchCV(estimator = KerasRegressor(build_fn = build_model), param_grid = param_grid) grid_result = grid.fit(x_train, y_train) grid_result.best_params_My sequential dense DNN seems to run through each parameter in my parameter grid three times while doing Grid Search. I expect it to run once per specified epcohs in the grid: 10, 50 and 100. Why does this happen?
model architecture:
def build_model(): print('building DNN architecture') model = Sequential() model.add(Dropout(0.02, input_shape = (150,))) model.add(Dense(8, init = 'normal', activation = 'relu')) model.add(Dropout(0.02)) model.add(Dense(16, init = 'normal', activation = 'relu')) model.add(Dense(1, init = 'normal')) model.compile(loss = 'mean_squared_error', optimizer = 'adam') print('model succesfully compiled') return modelGrid search on epochs:
from sklearn.model_selection import GridSearchCV epochs = [10,50,100] param_grid = dict(epochs = epochs) grid = GridSearchCV(estimator = KerasRegressor(build_fn = build_model), param_grid = param_grid) grid_result = grid.fit(x_train, y_train) grid_result.best_params_更多推荐
发布评论