我是NN的新手.我试图调整我的MLP回归模型.我不明白这条线是什么意思"'hidden\u layer\u Size':[(100,),(50100,),(50,75100,)]"这是否意味着我们要求模型判断如果只有一个隐藏层和100个隐藏点,或者两个隐藏层(有多少个神经元?)时,模型是否会表现更好还是三个隐藏层?

from sklearn.neural_network import MLPRegressor
from sklearn.model_selection import GridSearchCV
X, y = scaled_df[[ "Part's Z-Height (mm)","Part's Weight (N)","Part's Volume (cm^3)","Part's Surface Area (cm^2)","Part's Orientation (Support's height) (mm)","Part's Orientation (Support's volume) (cm^3)","Layer Height (mm)","Printing/Scanning Speed (mm/s)","Infill Density (%)"]], scaled_df [["Climate change (kg CO2 eq.)","Climate change, incl biogenic carbon (kg CO2 eq.)","Fine Particulate Matter Formation (kg PM2.5 eq.)","Fossil depletion (kg oil eq.)","Freshwater Consumption (m^3)","Freshwater ecotoxicity (kg 1,4-DB eq.)","Freshwater Eutrophication (kg P eq.)","Human toxicity, cancer (kg 1,4-DB eq.)","Human toxicity, non-cancer (kg 1,4-DB eq.)","Ionizing Radiation (Bq. C-60 eq. to air)","Land use (Annual crop eq. yr)","Marine ecotoxicity (kg 1,4-DB eq.)","Marine Eutrophication (kg N eq.)","Metal depletion (kg Cu eq.)","Photochemical Ozone Formation, Ecosystem (kg NOx eq.)","Photochemical Ozone Formation, Human Health (kg NOx eq.)","Stratospheric Ozone Depletion (kg CFC-11 eq.)","Terrestrial Acidification (kg SO2 eq.)","Terrestrial ecotoxicity (kg 1,4-DB eq.)"]]

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25, random_state=42)

mlp = MLPRegressor()
param_grid = {'hidden_layer_sizes': [(100,), (50,100,), (50,75,100,)],
              'activation': ['tanh','relu','lbfgs'],
              'solver': ['sgd', 'adam'],
              'learning_rate': ['constant','adaptive','invscaling'],
              'alpha': [0.0001, 0.05],
              'max_iter': [10000000000],
              'early_stopping': [False],
              'warm_start': [False]}
GS = GridSearchCV(mlp, param_grid=param_grid,n_jobs= -1,cv=5, scoring='r2')
                  
                  
GS.fit(X_train, y_train)

print(GS.best_params_)

推荐答案

是的,您正在执行Grid Search超参数优化.

  • 只有一个100个单元的隐藏层
  • 两个隐藏层50100
  • 3个隐藏层50、75、100

您的代码将提取超参数的所有组合,并告诉您哪一个表现最好.如果您只想提取其中的一些组合,可以查找RandomSearch.

Python相关问答推荐

为什么常规操作不以其就地对应操作为基础?

python—telegraph—bot send_voice发送空文件

循环浏览每个客户记录,以获取他们来自的第一个/最后一个渠道

在Google Drive中获取特定文件夹内的FolderID和文件夹名称

从源代码显示不同的输出(机器学习)(Python)

在我融化极点数据帧之后,我如何在不添加索引的情况下将其旋转回其原始形式?

用来自另一个数据框的列特定标量划分Polars数据框中的每一列,

Matplotlib中的曲线箭头样式

我如何为测试函数的参数化提供fixture 生成的数据?如果我可以的话,还有其他 Select 吗?

Django查询集-排除True值

使用Django标签显示信息

是否从Python调用SHGetKnownFolderPath?

在FastAPI/Starlette中使用WebSockets时如何运行后台任务?

Python:打开名称中带有最新时间戳的特定文件

当我的自定义对象用作Pydtic模型中的默认参数时,它不会被深度复制

用于从项目问题描述中提取文本的Selify代码

JAX在接受数组的简单函数上使用.grad:`ConcretizationTypeError:在需要具体值的地方遇到抽象跟踪器值`

真正的Python散布函数

如何从两对点得到一个二维变换矩阵?

将Python Web元素转换为txt,并使用打开文件txt