结合sklearn的例子理解神经网络的基本概念
2016-11-29 01:18
525 查看
先看代码(sklearn的示例代码):
MLPclassifier,MLP 多层感知器的的缩写(Multi-layer Perceptron)
fit(X,y) 与正常特征的输入输出相同
solver='lbfgs', MLP的求解方法:L-BFGS 在小数据上表现较好,Adam 较为鲁棒,SGD在参数调整较优时会有最佳表现(分类效果与迭代次数);
SGD标识随机梯度下降。疑问:SGD与反向传播算法的关系
alpha:L2的参数:MLP是可以支持正则化的,默认为L2,具体参数需要调整
hidden_layer_sizes=(5, 2) hidden层2层,第一层5个神经元,第二层2个神经元)
计算的时间复杂度(非常高。。。。):
Suppose there are n training samples, m features, k hidden layers, each containing h neurons - for simplicity, and o output neurons. The time complexity of backpropagation is O(n\cdot m \cdot h^k \cdot o \cdot i), where i is the number of iterations. Since
backpropagation has a high time complexity, it is advisable to start with smaller number of hidden neurons and few hidden layers for training.
涉及到的设置:隐藏层数量k,每层神经元数量h,迭代次数i。
整体计算流程:
输入:the input layer, consists of a set of neurons \{x_i | x_1, x_2, ..., x_m\} representing the input features
各个层间的计算: Each neuron in the hidden layer transforms the values from the previous layer with a weighted linear summation w_1x_1 + w_2x_2 + ... + w_mx_m, followed by a non-linear activation function g(\cdot):R \rightarrow R - like the hyperbolic tan function.
(疑问: 如果a non-linear activation function 是logit function 那么每个节点就是逻辑回归?,那么整个神经网络是变为多层的逻辑回归了么?)
输出:The output layer receives the values from the last hidden layer and transforms them into output values
from sklearn.neural_network import MLPClassifier X = [[0., 0.], [1., 1.]] y = [0, 1] clf = MLPClassifier(solver='lbfgs', alpha=1e-5, hidden_layer_sizes=(5, 2), random_state=1) clf.fit(X, y) print 'predict\t',clf.predict([[2., 2.], [-1., -2.]]) print 'predict\t',clf.predict_proba([[2., 2.], [1., 2.]]) print 'clf.coefs_ contains the weight matrices that constitute the model parameters:\t',[coef.shape for coef in clf.coefs_] print clf c=0 for i in clf.coefs_: c+=1 print c,len(i),i说明:
MLPclassifier,MLP 多层感知器的的缩写(Multi-layer Perceptron)
fit(X,y) 与正常特征的输入输出相同
solver='lbfgs', MLP的求解方法:L-BFGS 在小数据上表现较好,Adam 较为鲁棒,SGD在参数调整较优时会有最佳表现(分类效果与迭代次数);
SGD标识随机梯度下降。疑问:SGD与反向传播算法的关系
alpha:L2的参数:MLP是可以支持正则化的,默认为L2,具体参数需要调整
hidden_layer_sizes=(5, 2) hidden层2层,第一层5个神经元,第二层2个神经元)
计算的时间复杂度(非常高。。。。):
Suppose there are n training samples, m features, k hidden layers, each containing h neurons - for simplicity, and o output neurons. The time complexity of backpropagation is O(n\cdot m \cdot h^k \cdot o \cdot i), where i is the number of iterations. Since
backpropagation has a high time complexity, it is advisable to start with smaller number of hidden neurons and few hidden layers for training.
涉及到的设置:隐藏层数量k,每层神经元数量h,迭代次数i。
整体计算流程:
输入:the input layer, consists of a set of neurons \{x_i | x_1, x_2, ..., x_m\} representing the input features
各个层间的计算: Each neuron in the hidden layer transforms the values from the previous layer with a weighted linear summation w_1x_1 + w_2x_2 + ... + w_mx_m, followed by a non-linear activation function g(\cdot):R \rightarrow R - like the hyperbolic tan function.
(疑问: 如果a non-linear activation function 是logit function 那么每个节点就是逻辑回归?,那么整个神经网络是变为多层的逻辑回归了么?)
输出:The output layer receives the values from the last hidden layer and transforms them into output values
相关文章推荐
- 神经网络基本概念
- 神经网络基本概念
- 关于机器学习神经网络的基本理解
- Tensorflow中基本概念及神经网络模型的介绍
- 深度学习-基础概念:神经元(Neurons)、Sigmoid 函数与神经网络基本结构
- 神经网络基本的一些概念
- [网络]几个基本概念的理解:什么是冲突域,广播域,广播地址,网络地址
- 机器学习笔记(XIV)神经网络(I)基本概念
- 理解神经网络,从简单的例子开始(1)7行python代码构建神经网络
- 训练神经网络中最基本的三个概念:Epoch, Batch, Iteration
- 神经网络基本概念
- 深度神经网络概述:从基本概念到实际模型和硬件基础
- 神经网络学习笔记-01-基本概念
- RNN循环神经网络的直观理解:基于TensorFlow的简单RNN例子
- 深入理解Neutron -- OpenStack网络实践:概述和基本概念
- Deep Learning 学习系列001 —— 神经网络基本概念
- 神经网络概念理解
- 【深度学习 论文综述】深度神经网络全面概述:从基本概念到实际模型和硬件基础
- 神经网络的一些概念理解
- TensorFlow入门,基本介绍,基本概念,计算图,pip安装,helloworld示例,实现简单的神经网络