1. 程式人生 > >sklearn 神經網路 MLPClassifier 引數詳解

sklearn 神經網路 MLPClassifier 引數詳解

轉載自  http://blog.csdn.net/haiyu94/article/details/53001726

引數說明: 

1. hidden_layer_sizes :元祖格式,長度=n_layers-2, 預設(100,),第i個元素表示第i個隱藏層的神經元的個數。 
2. activation :{‘identity’, ‘logistic’, ‘tanh’, ‘relu’}, 預設‘relu 
- ‘identity’: no-op activation, useful to implement linear bottleneck, 
返回f(x) = x 
- ‘logistic’:the logistic sigmoid function, returns f(x) = 1 / (1 + exp(-x)). 

- ‘tanh’:the hyperbolic tan function, returns f(x) = tanh(x). 
- ‘relu’:the rectified linear unit function, returns f(x) = max(0, x) 
4. solver: {‘lbfgs’, ‘sgd’, ‘adam’}, 預設 ‘adam’,用來優化權重 
- lbfgs:quasi-Newton方法的優化器 
- sgd:隨機梯度下降 
- adam: Kingma, Diederik, and Jimmy Ba提出的機遇隨機梯度的優化器 
注意:預設solver ‘adam’在相對較大的資料集上效果比較好(幾千個樣本或者更多),對小資料集來說,lbfgs收斂更快效果也更好。 

5. alpha :float,可選的,預設0.0001,正則化項引數 
6. batch_size : int , 可選的,預設‘auto’,隨機優化的minibatches的大小,如果solver是‘lbfgs’,分類器將不使用minibatch,當設定成‘auto’,batch_size=min(200,n_samples) 
7. learning_rate :{‘constant’,‘invscaling’, ‘adaptive’},預設‘constant’,用於權重更新,只有當solver為’sgd‘時使用 
- ‘constant’: 有‘learning_rate_init’給定的恆定學習率 
- ‘incscaling’:隨著時間t使用’power_t’的逆標度指數不斷降低學習率
learning_rate_ ,effective_learning_rate = learning_rate_init / pow(t, power_t) 
- ‘adaptive’:只要訓練損耗在下降,就保持學習率為’learning_rate_init’不變,當連續兩次不能降低訓練損耗或驗證分數停止升高至少tol時,將當前學習率除以5. 
8. max_iter: int,可選,預設200,最大迭代次數。 
9. random_state:int 或RandomState,可選,預設None,隨機數生成器的狀態或種子。 
10. shuffle: bool,可選,預設True,只有當solver=’sgd’或者‘adam’時使用,判斷是否在每次迭代時對樣本進行清洗。 
11. tol:float, 可選,預設1e-4,優化的容忍度 
12. learning_rate_int:double,可選,預設0.001,初始學習率,控制更新權重的補償,只有當solver=’sgd’ 或’adam’時使用。 
13. power_t: double, optional, default 0.5,只有solver=’sgd’時使用,是逆擴充套件學習率的指數.當learning_rate=’invscaling’,用來更新有效學習率。 
14. verbose : bool, optional, default False,是否將過程列印到stdout 
15. warm_start : bool, optional, default False,當設定成True,使用之前的解決方法作為初始擬合,否則釋放之前的解決方法。 
16. momentum : float, default 0.9,Momentum(動量) for gradient descent update. Should be between 0 and 1. Only used when solver=’sgd’. 
17. nesterovs_momentum : boolean, default True, Whether to use Nesterov’s momentum. Only used when solver=’sgd’ and momentum > 0. 
18. early_stopping : bool, default False,Only effective when solver=’sgd’ or ‘adam’,判斷當驗證效果不再改善的時候是否終止訓練,當為True時,自動選出10%的訓練資料用於驗證並在兩步連續爹迭代改善低於tol時終止訓練。 
19. validation_fraction : float, optional, default 0.1,用作早期停止驗證的預留訓練資料集的比例,早0-1之間,只當early_stopping=True有用 
20. beta_1 : float, optional, default 0.9,Only used when solver=’adam’,估計一階矩向量的指數衰減速率,[0,1)之間 
21. beta_2 : float, optional, default 0.999,Only used when solver=’adam’估計二階矩向量的指數衰減速率[0,1)之間 
22. epsilon : float, optional, default 1e-8,Only used when solver=’adam’數值穩定值。 
屬性說明: 
classes_:每個輸出的類標籤 
loss_:損失函式計算出來的當前損失值 
coefs_:列表中的第i個元素表示i層的權重矩陣 
intercepts_:列表中第i個元素代表i+1層的偏差向量 
n_iter_ :迭代次數 
n_layers_:層數 
n_outputs_:輸出的個數 
out_activation_:輸出啟用函式的名稱。 
方法說明: 
fit(X,y):擬合 
get_params([deep]):獲取引數 
predict(X):使用MLP進行預測 
predic_log_proba(X):返回對數概率估計 
predic_proba(X):概率估計 
score(X,y[,sample_weight]):返回給定測試資料和標籤上的平均準確度 
-set_params(**params):設定引數。