zoukankan      html  css  js  c++  java
  • MLPclassifier,MLP 多层感知器的的缩写(Multi-layer Perceptron)

     

    先看代码(sklearn的示例代码):

    [python] view plain copy
    1. from sklearn.neural_network import MLPClassifier  
    2.     X = [[0., 0.], [1., 1.]]  
    3.     y = [0, 1]  
    4.   
    5.     clf = MLPClassifier(solver='lbfgs', alpha=1e-5,  
    6.                     hidden_layer_sizes=(5, 2), random_state=1)  
    7.   
    8.     clf.fit(X, y)  
    9.     print 'predict ',clf.predict([[2., 2.], [-1., -2.]])  
    10.     print 'predict ',clf.predict_proba([[2., 2.], [1., 2.]])  
    11.     print 'clf.coefs_ contains the weight matrices that constitute the model parameters: ',[coef.shape for coef in clf.coefs_]  
    12.     print clf  
    13.     c=0  
    14.     for i in clf.coefs_:  
    15.         c+=1  
    16.         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(ncdot 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。

  • 相关阅读:
    js 中将 ‘Thu, 20 Feb 2020 14:21:15 GMT’ 转成 ‘yyyy-mm-dd hh:dd:ss’
    mysql 操作
    flask+bootstrap 页面查询、分页
    bootstrap静态框,调后端接口结果展示
    UndefinedError: 'int' is undefined 解决
    robot framework web自动化-登录
    robot framework 执行web自动化一次后没有log日志,重启后执行一次后也是
    robot framework 数据库增删改查
    robot framework get、post 接口调用
    PCM-FTL
  • 原文地址:https://www.cnblogs.com/bonelee/p/7880867.html
Copyright © 2011-2022 走看看