在神经网络中的时代网格搜索:每个参数运行3次(Grid search on epochs in neural network: each parameter being run 3 times)

编程入门 行业动态 更新时间:2024-10-15 22:23:04
神经网络中的时代网格搜索:每个参数运行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 model

Grid 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_

更多推荐

本文发布于:2023-07-07 04:05:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1058716.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:神经网络   网格   参数   时代   Grid

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!