简体   繁体   English

神经网络与线性回归

[英]Neural Network vs Linear regression

We know that the neural network will perform like a linear regression if there is only one hidden unit.我们知道,如果只有一个隐藏单元,神经网络将像线性回归一样执行。 So, the NN method should perform at least as well as a linear regression method.因此,NN 方法的性能至少应该与线性回归方法一样好。 I have built a tidymodel model using the following line of code:我使用以下代码行构建了一个 tidymodel model:

Data_nnet_mod <-  mlp(hidden_units = tune(),  penalty = tune(),  epochs = tune()) %>% 
  set_engine("nnet") %>% 
  set_mode("regression") 

and have tuned it using并使用

Data_nnet_fit <- 
  Data_nnet_wflow %>%  
  tune_grid(val_set,
            grid = 25,
            control = control_grid(save_pred = TRUE),
            metrics = metric_set(rmse))

It turns out that the linear regression output has a smaller RMSE than the NN method.事实证明,线性回归 output 的 RMSE 小于 NN 方法。

I wonder why the best RMSE that the NN method produces is larger than that of the regression method.我想知道为什么 NN 方法产生的最佳 RMSE 大于回归方法。 Theoretically speaking, should the NN method not be at least as well as the regression method?从理论上讲,NN方法不应该至少和回归方法一样好吗?

A neural network with one hidden unit and linear activation is linear regression.具有一个隐藏单元和线性激活的神经网络线性回归。 There may be differences though, for example, neural networks are usually trained with variants of gradient descent, while linear regression with ordinary least squares , so you have no guarantees that they end up with the same results.尽管可能存在差异,例如,神经网络通常使用梯度下降的变体进行训练,而线性回归使用普通最小二乘法进行训练,因此您无法保证它们最终得到相同的结果。 There also may be implementation details that differ.也可能存在不同的实现细节。 If you use regularization, other activation, loss, etc those would be different models so again you have no guarantees of finding the same solution, or an equally good one.如果您使用正则化、其他激活、损失等,这些将是不同的模型,因此您无法保证找到相同的解决方案或同样好的解决方案。 Unless both models are exactly the same, you don't really have guarantees of same performance.除非两个模型完全相同,否则您并不能真正保证相同的性能。 Because all of the above reasons, linear regression may outperform neural networks for regression problems, or logistic regression can for classification .由于上述所有原因,线性回归在回归问题上可能优于神经网络,或者逻辑回归在分类问题上可能优于神经网络。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM