Spark機器學習(12):神經網路演算法

来源:http://www.cnblogs.com/mstk/archive/2017/07/27/7245832.html
-Advertisement-
Play Games

1. 神經網路基礎知識 1.1 神經元 神經網路(Neural Net)是由大量的處理單元相互連接形成的網路。神經元是神經網路的最小單元,神經網路由若幹個神經元組成。一個神經元的結構如下: 上面的神經元x1,x2,x3和1是輸入,hw,b(x)是輸出。 其中f(x)是激活函數,常用的激活函數有sig ...


1. 神經網路基礎知識

1.1 神經元

神經網路(Neural Net)是由大量的處理單元相互連接形成的網路。神經元是神經網路的最小單元,神經網路由若幹個神經元組成。一個神經元的結構如下:

上面的神經元x1,x2,x3和1是輸入,hw,b(x)是輸出。

其中f(x)是激活函數,常用的激活函數有sigmoid函數和tanh(雙曲正切)函數。

sigmoid函數:

tanh(雙曲正切)函數:

1.2 神經網路

神經網路由若幹個層次,相鄰層次之間的神經元存在輸入的關係。第一層稱為輸入層,最後一層稱為輸出層,中間的層次稱為隱含層。

1.3 信號前向傳播和誤差反向傳播

設神經網路有n層,第1層為L1,第2層為L2,第n層為Ln,第p(p=1,2,...n)層的神經元節點數量是mp。aj(k)表示第k層第j個節點的輸出值。則對於L1(也就是輸入層),有

第(k+1)層第j個神經元的輸出

設一個訓練樣本的誤差為

整體誤差函數

 

為了防止過擬合,增加了第二項L2正則化。

目標是求(w,b),使得J(w,b)最小。為此使用梯度下降法,每次迭代按照下麵的公式對w和b進行更新

第n層(也就是輸出層)的輸出神經元j,其殘差為

第k層第i個節點的殘差為

求解(w,b)的過程如下:

1) 對於所有的k,令w(k):=0,b(k):=0;

2) 信號前向傳播,根據每個樣本的輸入值和w(k)、w(k),逐層計算出hw,b(x);

3) 誤差反向傳播,逐層計算出每一層每個神經元的殘差;

4) 對w和b的值進行更新。

反覆進行步驟(2)~(4),直到完成指定的迭代次數為止。

2. MLlib神經網路的實現

MLlib的神經網路類是NerualNet。主要參數包括:

Size:Array[Int],神經網路每一層的節點數量;

Layer:神經網路的層數;

Activation_function:激活函數,可以是sigm或tanh

Ouput_function:輸出函數,可以是sigm、softmax或linear。

代碼:

import org.apache.log4j.{ Level, Logger }
import org.apache.spark.{ SparkConf, SparkContext }
import breeze.linalg.{
DenseMatrix => BDM,
max => Bmax,
min => Bmin
}
import scala.collection.mutable.ArrayBuffer

/**
  * Created by Administrator on 2017/7/27.
  */
object NNTest {

  def main(args: Array[String]) = {
    // 設置運行環境
    val conf = new SparkConf().setAppName("Neural Net")
      .setMaster("spark://master:7077").setJars(Seq("E:\\Intellij\\Projects\\MachineLearning\\MachineLearning.jar"))
    val sc = new SparkContext(conf)
    Logger.getRootLogger.setLevel(Level.WARN)

    // 隨機生成樣本數據
    Logger.getRootLogger.setLevel(Level.WARN)
    val sampleRow = 1000
    val sampleColumn = 5
    val randSamp_01 = RandSampleData.RandM(sampleRow, sampleColumn, -10, 10, "sphere")
    // 歸一化
    val norMax = Bmax(randSamp_01(::, breeze.linalg.*))
    val norMin = Bmin(randSamp_01(::, breeze.linalg.*))
    val nor1 = randSamp_01 - (BDM.ones[Double](randSamp_01.rows, 1)) * norMin
    val nor2 = nor1 :/ ((BDM.ones[Double](nor1.rows, 1)) * (norMax - norMin))
    // 轉換樣本
    val randSamp_02 = ArrayBuffer[BDM[Double]]()
    for (i <- 0 to sampleRow - 1) {
      val mi = nor2(i, ::)
      val mi1 = mi.inner
      val mi2 = mi1.toArray
      val mi3 = new BDM(1, mi2.length, mi2)
      randSamp_02 += mi3
    }
    val randSamp_03 = sc.parallelize(randSamp_02, 10)
    sc.setCheckpointDir("hdfs://master:9000/ml/data/checkpoint")
    randSamp_03.checkpoint()
    val trainRDD = randSamp_03.map(f => (new BDM(1, 1, f(::, 0).data), f(::, 1 to -1)))
    // 訓練,建立模型
    val opts = Array(100.0, 50.0, 0.0)
    trainRDD.cache
    val numExamples = trainRDD.count()
    println(s"Number of Examples: $numExamples")
    val NNModel = new NeuralNet().
      setSize(Array(5, 10, 10, 10, 10, 10, 1)).
      setLayer(7).
      setActivation_function("tanh_opt").
      setLearningRate(2.0).
      setScaling_learningRate(1.0).
      setWeightPenaltyL2(0.0).
      setNonSparsityPenalty(0.0).
      setSparsityTarget(0.05).
      setInputZeroMaskedFraction(0.0).
      setDropoutFraction(0.0).
      setOutput_function("sigm").
      NNtrain(trainRDD, opts)

    // 測試模型
    val NNPrediction = NNModel.predict(trainRDD)
    val NNPredictionError = NNModel.Loss(NNPrediction)
    println(s"NNerror = $NNPredictionError")
    val showPrediction = NNPrediction.map(f => (f.label.data(0), f.predict_label.data(0))).take(100)
    println("Prediction Result")
    println("Value" + "\t" + "Prediction" + "\t" + "Error")
    for (i <- 0 until showPrediction.length)
      println(showPrediction(i)._1 + "\t" + showPrediction(i)._2 + "\t" + (showPrediction(i)._2 - showPrediction(i)._1))

    var tmpWeight = NNModel.weights(0)
    for (i <-0 to 5) {
      tmpWeight = NNModel.weights(i)
      println(s"Weight of Layer ${i+1}")
      for (j <- 0 to tmpWeight.rows - 1) {
        for (k <- 0 to tmpWeight.cols - 1) {
          print(tmpWeight(j, k) + "\t")
        }
        println()
      }
    }

  }

}

以上代碼建立了一個7層的神經網路,各層的節點數量為Array(5, 10, 10, 10, 10, 10, 1),對Sphere函數進行了測試。

運行結果:

Number of Examples: 1000
epoch: numepochs = 1 , Took = 17 seconds; Full-batch train mse = 0.066738, val mse = 0.000000.
epoch: numepochs = 2 , Took = 12 seconds; Full-batch train mse = 0.069649, val mse = 0.000000.
epoch: numepochs = 3 , Took = 10 seconds; Full-batch train mse = 0.055260, val mse = 0.000000.
epoch: numepochs = 4 , Took = 10 seconds; Full-batch train mse = 0.016346, val mse = 0.000000.
epoch: numepochs = 5 , Took = 9 seconds; Full-batch train mse = 0.013802, val mse = 0.000000.
epoch: numepochs = 6 , Took = 13 seconds; Full-batch train mse = 0.045142, val mse = 0.000000.
epoch: numepochs = 7 , Took = 7 seconds; Full-batch train mse = 0.031211, val mse = 0.000000.
epoch: numepochs = 8 , Took = 7 seconds; Full-batch train mse = 0.016334, val mse = 0.000000.
epoch: numepochs = 9 , Took = 9 seconds; Full-batch train mse = 0.013348, val mse = 0.000000.
epoch: numepochs = 10 , Took = 7 seconds; Full-batch train mse = 0.017879, val mse = 0.000000.
epoch: numepochs = 11 , Took = 7 seconds; Full-batch train mse = 0.012627, val mse = 0.000000.
epoch: numepochs = 12 , Took = 7 seconds; Full-batch train mse = 0.018080, val mse = 0.000000.
epoch: numepochs = 13 , Took = 7 seconds; Full-batch train mse = 0.016755, val mse = 0.000000.
epoch: numepochs = 14 , Took = 7 seconds; Full-batch train mse = 0.012250, val mse = 0.000000.
epoch: numepochs = 15 , Took = 7 seconds; Full-batch train mse = 0.044833, val mse = 0.000000.
epoch: numepochs = 16 , Took = 7 seconds; Full-batch train mse = 0.024345, val mse = 0.000000.
epoch: numepochs = 17 , Took = 7 seconds; Full-batch train mse = 0.039005, val mse = 0.000000.
epoch: numepochs = 18 , Took = 7 seconds; Full-batch train mse = 0.012298, val mse = 0.000000.
epoch: numepochs = 19 , Took = 7 seconds; Full-batch train mse = 0.012371, val mse = 0.000000.
epoch: numepochs = 20 , Took = 6 seconds; Full-batch train mse = 0.014077, val mse = 0.000000.
epoch: numepochs = 21 , Took = 7 seconds; Full-batch train mse = 0.040328, val mse = 0.000000.
epoch: numepochs = 22 , Took = 6 seconds; Full-batch train mse = 0.036575, val mse = 0.000000.
epoch: numepochs = 23 , Took = 6 seconds; Full-batch train mse = 0.033986, val mse = 0.000000.
epoch: numepochs = 24 , Took = 6 seconds; Full-batch train mse = 0.026421, val mse = 0.000000.
epoch: numepochs = 25 , Took = 6 seconds; Full-batch train mse = 0.036776, val mse = 0.000000.
epoch: numepochs = 26 , Took = 6 seconds; Full-batch train mse = 0.011838, val mse = 0.000000.
epoch: numepochs = 27 , Took = 6 seconds; Full-batch train mse = 0.010749, val mse = 0.000000.
epoch: numepochs = 28 , Took = 6 seconds; Full-batch train mse = 0.012717, val mse = 0.000000.
epoch: numepochs = 29 , Took = 6 seconds; Full-batch train mse = 0.011883, val mse = 0.000000.
epoch: numepochs = 30 , Took = 7 seconds; Full-batch train mse = 0.010562, val mse = 0.000000.
epoch: numepochs = 31 , Took = 6 seconds; Full-batch train mse = 0.010591, val mse = 0.000000.
epoch: numepochs = 32 , Took = 6 seconds; Full-batch train mse = 0.010389, val mse = 0.000000.
epoch: numepochs = 33 , Took = 6 seconds; Full-batch train mse = 0.015908, val mse = 0.000000.
epoch: numepochs = 34 , Took = 6 seconds; Full-batch train mse = 0.012413, val mse = 0.000000.
epoch: numepochs = 35 , Took = 6 seconds; Full-batch train mse = 0.010442, val mse = 0.000000.
epoch: numepochs = 36 , Took = 6 seconds; Full-batch train mse = 0.056686, val mse = 0.000000.
epoch: numepochs = 37 , Took = 6 seconds; Full-batch train mse = 0.054850, val mse = 0.000000.
epoch: numepochs = 38 , Took = 6 seconds; Full-batch train mse = 0.019422, val mse = 0.000000.
epoch: numepochs = 39 , Took = 6 seconds; Full-batch train mse = 0.016443, val mse = 0.000000.
epoch: numepochs = 40 , Took = 6 seconds; Full-batch train mse = 0.010289, val mse = 0.000000.
epoch: numepochs = 41 , Took = 7 seconds; Full-batch train mse = 0.022615, val mse = 0.000000.
epoch: numepochs = 42 , Took = 6 seconds; Full-batch train mse = 0.010723, val mse = 0.000000.
epoch: numepochs = 43 , Took = 6 seconds; Full-batch train mse = 0.010289, val mse = 0.000000.
epoch: numepochs = 44 , Took = 6 seconds; Full-batch train mse = 0.033933, val mse = 0.000000.
epoch: numepochs = 45 , Took = 7 seconds; Full-batch train mse = 0.030156, val mse = 0.000000.
epoch: numepochs = 46 , Took = 7 seconds; Full-batch train mse = 0.022068, val mse = 0.000000.
epoch: numepochs = 47 , Took = 7 seconds; Full-batch train mse = 0.029382, val mse = 0.000000.
epoch: numepochs = 48 , Took = 6 seconds; Full-batch train mse = 0.021275, val mse = 0.000000.
epoch: numepochs = 49 , Took = 6 seconds; Full-batch train mse = 0.039427, val mse = 0.000000.
epoch: numepochs = 50 , Took = 7 seconds; Full-batch train mse = 0.016674, val mse = 0.000000.
NNerror = 0.016674267332022572
Prediction Result
Value    Prediction    Error
0.6048934040010798    0.19097551722554007    -0.41391788677553976
0.5917463309959767    0.35726681238891195    -0.23447951860706479
0.5798180746808277    0.19232727566724744    -0.38749079901358024
0.39808885303777447    0.1926440400752866    -0.20544481296248787
0.4140924247674261    0.19529777426853168    -0.2187946504988944
0.08847408598189055    0.19110126347316514    0.10262717749127459
0.3583460134199821    0.21170344602417424    -0.1466425673958079
0.29635258460747904    0.3549086780038481    0.05855609339636908
0.21947238532147648    0.19156569159762857    -0.02790669372384791
0.5357166982629155    0.36018248221537214    -0.17553421604754332
0.5547810234563126    0.1912501730851674    -0.36353085037114524
0.40529948654006304    0.21826323152039923    -0.1870362550196638
0.4765320387665492    0.34409113646061484    -0.13244090230593436
0.05759629179315594    0.1914373047341408    0.13384101294098488
0.25415182638221206    0.29169483353745973    0.037543007155247665
0.2731217394258585    0.19452719525740314    -0.07859454416845535
0.021103715077802527    0.19131792203441428    0.17021420695661174
0.24098254783013137    0.334302879677641    0.09332033184750962
0.6300811731076671    0.3595001582783692    -0.2705810148292979
0.41827613603130404    0.195477735057971    -0.22279840097333303
0.2526404805902617    0.1945578268820965    -0.05808265370816518
0.16619916368077442    0.191265206532793    0.025066042852018577
0.007724491831775392    0.1909446242319318    0.1832201324001564
0.08926696720959378    0.19197139383958237    0.10270442662998859
0.4822857005955674    0.19244393418394434    -0.28984176641162307
0.12166559083216193    0.19242076231047756    0.07075517147831563
0.2883494676971952    0.30939742289582284    0.02104795519862762
0.38817298742061984    0.1909921814285587    -0.19718080599206114
0.34588396966368695    0.1957690915303307    -0.15011487813335625
0.19958641570784796    0.19348928314854685    -0.0060971325593011105
0.31340425691874024    0.19828489007869293    -0.11511936684004731
0.31775749422734    0.19211592601952254    -0.12564156820781747
0.48789392695999645    0.19120722177454247    -0.296686705185454
0.4359840834351843    0.3604340050247724    -0.07555007841041189
0.17359981155470314    0.1914334455263964    0.01783363397169327
0.3629355770221922    0.2004476969345776    -0.1624878800876146
0.4627621372503198    0.2111988404691097    -0.2515632967812101
0.49652077030838826    0.19101585452942166    -0.3055049157789666
0.12618599928245963    0.19939585850613975    0.07320985922368012
0.45276204270081455    0.1924159942977412    -0.26034604840307335
0.2837721853443281    0.2016124468403725    -0.08215973850395558
0.34590164213713354    0.3601210376231753    0.014219395486041786
0.1961497656762427    0.19408639222665872    -0.0020633734495839884
0.22135763175909048    0.27616370537642354    0.054806073617333056
0.43356473411523927    0.19150317510575426    -0.242061559009485
0.09566706862199378    0.19087327269062435    0.09520620406863056
0.29830626566849494    0.19959705355592236    -0.09870921211257258
0.3070532379895792    0.34322116560057725    0.036167927610998074
0.07052673330364767    0.19118739087384276    0.12066065757019509
0.5501181200918814    0.2024015375945202    -0.34771658249736126
0.31894277127298554    0.1917670097886867    -0.12717576148429885
0.08585450906008718    0.20848620726607436    0.12263169820598718
0.20245657700014166    0.19218060734066275    -0.010275969659478912
0.1712767340967007    0.1913375355437103    0.020060801447009613
0.3779192242827297    0.2035011707996587    -0.17441805348307102
0.241909871430447    0.19089783315658176    -0.051012038273865246
0.40578032667620945    0.3561807946562045    -0.049599532020004944
0.20834390560196567    0.19103138812628986    -0.017312517475675804
0.49675932490421343    0.1915234454414188    -0.3052358794627946
0.2342257039800733    0.1920213029433058    -0.04220440103676751
0.18045883957051312    0.20420037376704497    0.023741534196531855
0.2309607430153665    0.1912620988835584    -0.0396986441318081
0.40644947116571745    0.19173032204451546    -0.214719149121202
0.11691561072493983    0.19280159115148832    0.07588598042654848
0.05696889589626215    0.19083593927270395    0.13386704337644179
0.47164532559761124    0.2506614607550888    -0.22098386484252242
0.6208470748110626    0.35822718159638256    -0.26261989321468004
0.46559040490785325    0.2083058633813562    -0.25728454152649705
0.5052214973114583    0.19867901868911944    -0.30654247862233885
0.4127229537166962    0.35982142534462497    -0.05290152837207124
0.16960925650784137    0.19135483819811452    0.021745581690273158
0.19722393334464125    0.19080547758699506    -0.006418455757646185
0.4335762052660574    0.20920751654239156    -0.22436868872366583
0.1496556423910719    0.19090570957335065    0.04125006718227875
0.3015215343928844    0.1922591754560472    -0.10926235893683722
0.0    0.19143943303505245    0.19143943303505245
0.36555981464056164    0.19189800228180368    -0.17366181235875797
0.3963164889187304    0.19451555510717428    -0.20180093381155612
0.313325868748335    0.19168776655589245    -0.12163810219244256
0.5034713123520999    0.3339326133308013    -0.16953869902129853
0.4224576693623929    0.3539965263782299    -0.06846114298416295
0.08523050351506854    0.19132247714662606    0.10609197363155752
0.26080914691197654    0.19095418139777426    -0.06985496551420228
0.1324640982588358    0.19304336020222349    0.0605792619433877
0.13055674031551295    0.19224589387242375    0.06168915355691079
0.23625412018106318    0.1917614371123628    -0.044492683068700384
0.5019570376831385    0.3081554524341633    -0.19380158524897517
0.030390738837917763    0.19083521852879112    0.16044447969087336
0.34274552561551896    0.19120112478612986    -0.1515444008293891
0.4514974655646171    0.1916124319598441    -0.259885033604773
0.531777023034474    0.3515396924867077    -0.18023733054776636
0.367772718094668    0.3317275143536775    -0.03604520374099052
0.41600472261866916    0.22278029398575255    -0.1932244286329166
0.36506543552315474    0.325628070833062    -0.039437364690092735
0.314008782918081    0.32408907795815034    0.010080295040069354
0.2925887989109779    0.1921158349811155    -0.10047296392986238
0.4658619691058588    0.2146831464338164    -0.2511788226720424
0.2280242270958607    0.19158705334902099    -0.03643717374683972
0.5003581077100195    0.19149431703681175    -0.3088637906732078
0.4448442553362914    0.19086228548828346    -0.2539819698480079
Weight of Layer 1
1.3741710823232989    1.0997962988037757    -2.3077515870713716    2.0946962013291297    2.24588083756021    0.7186952475525394    
-1.1885813301306254    0.25046447165487246    -1.253986920617667    1.535570764339994    0.1440090623878452    1.2110656874633237    
-0.23784821158321864    -0.5133767761738681    0.5355594752965599    -0.9862762256909807    2.234245108441277    -0.5216923380767392    
2.0496153507146033    -0.9000455162282417    1.3406201642695788    2.1185256789014897    1.038387978643167    -0.011886136436036997    
2.4017180810229086    0.5342060426581219    2.188686239727936    -0.604587031465719    0.061697537675081446    -0.48429030459304306    
-1.234468451038262    0.7790398934631602    -0.22067594788975725    -2.0414139797176176    -0.9324514648411226    0.798505045375407    
0.843464180836847    1.8612698144445792    2.290144904438349    1.2291878648431667    2.3639566790099784    -2.1175568466779437    
2.1488480623696975    2.253851655104785    -1.879142801282798    -0.23011616258273254    2.4342506675413413    -2.184430097374211    
1.3446335417651347    0.39411399422872706    -1.4588967794444714    2.6567285233270366    -0.8576819932211762    -1.9914472547514181    
1.4277752508742856    0.6379599194760166    -0.3783031968398195    1.4158689111045317    1.5318358789872808    -1.201612551759085    
Weight of Layer 2
-1.264966034912716    2.045363428231917    0.39087016834115496    1.0930481252787911    -1.571245354275874    -0.9655062462170442    2.1709800176902982    -1.025175316866544    -1.5230797088149843    1.769571487127593    0.2347823358786302    
-0.7297761283100554    -0.7576138927387723    -0.16523415352888424    -1.8516805610014189    1.3715533800487367    1.95737270209438    0.08246852496952446    1.0190398538209786    0.38679398113645574    0.529334650423367    0.43356573369591683    
-1.494114816211369    0.47441528091212    -0.4329092188524354    1.8318597886945986    1.7458297556728688    -2.0957897682487707    -0.12195567981037991    0.0378548041005975    -0.6616871154791367    -1.2988919749370011    -2.0146727073983346    
-2.0369675326219587    -0.6502946004953208    -0.5031500283188425    1.2033687522496184    -0.35900710238718897    -1.213965816985491    -0.6247306519040674    -1.172636102729738    0.1492977187034359    0.7805087252939967    0.42756349073372346    
1.9444610499195103    -1.684949676049153    -2.214370792742285    1.4529568002779754    -0.817314868362314    -2.0437576009396534    1.414190131329268    0.8002930022447152    0.5103985267247684    1.072725074367445    0.7728306875824079    
1.3280098832755556    -0.5723175992914568    1.8965322712004982    1.9131475857947766    0.7116308703102919    -1.1337078046228692    1.4624037563264591    -1.2661436485440505    0.2074359557718086    1.7605365810734208    0.5503309132836761    
-0.12889849968368497    -1.5813673816630978    0.3179522409763945    -1.4093501587164268    0.37747278027064335    2.0973248562810287    1.3796729017078182    -1.32247724141541    0.05176617793309023    0.2797968400006565    0.2649190482622152    
0.3553074482253876    -1.236624823614366    -1.7608721088406603    1.0024974314351445    -2.174840973945128    -0.6578975450189226    2.301788638015837    1.1479110741419556    -0.3844810208733819    -1.757161551068665    0.005888873948249745    
1.0889152043326655    -0.4907523692459491    -1.5314215158890179    -2.068119203282905    -0.6966652421295678    1.7172836960101752    -1.030902225947676    1.7894526684520087    1.5213695041770878    -2.0310793395869613    -0.23638299504893515    
-0.9900330517352804    -1.0052522373970076    -0.25640336055482327    0.5747216493939299    -0.6727702236294272    -0.0968976241335074    1.828632192751469    -1.2027447051840479    1.462449341909922    1.866886724932346    0.337038328583328    
Weight of Layer 3
1.836452591890687    -1.1016514469136454    1.9551193591759655    -1.5732459452330396    -1.1800834414335224    -1.1923893040285825    0.06312897816177482    1.457981772832194    1.7288840730921886    1.0295473067747805    -0.6835578234742354    
-1.281488825782123    1.9855453373804615    -0.21337154884305315    -0.8204219180246067    -0.8260103421573441    -1.3974890573670238    -0.18789338539658415    1.5852967650612315    -0.9475186470859063    -1.0100358806860719    1.0069697324461917    
0.7336707009234793    -0.8190101361063539    -1.9821987263863545    -2.0789438096783956    -1.1812929830305807    -0.12007384037833814    -1.8876632918570322    -0.8968914717818263    1.3471019678011835    -0.152196929664138    -0.9273968120578239    
-0.5427506117781439    -1.6379161635634556    1.6603536697042776    -0.2826332939784261    -1.7089295991871511    -0.3086776080327076    -0.838637438570992    0.45911079203796323    0.26754055606009786    -1.8482009521236713    -0.23130366979329475    
-0.37585662596248814    0.4900765346436331    0.6860109049091877    -0.9572551404136589    0.30380993421860114    -1.73380834254428    -0.9187544507012596    -2.143513804630084    1.9614638862521159    0.513675117374747    1.7364284348955028    
1.4300160181482728    -0.028644837063659466    0.9434705098905873    -1.256117787020064    -2.286119449246773    0.8392807137479158    1.0463524997789728    0.22524746294136241    -2.065346398428731    -1.3984782782329925    0.8064849904915904    
-0.020036943079112954    1.3571828713761132    1.8168106691174883    1.1732287314521193    -1.1216050426635968    -0.7992471983374778    1.4737000544885857    -1.2629467521609772    -2.166720398969067    -0.13444189253030867    -0.06990910534870051    
-1.1475378284991893    0.7939976065553747    -0.6034315465733754    1.2609824176884306    -1.0556544940783124    -1.2600392532679041    0.20515032057156965    -0.9368115470081553    1.8486189613353239    -1.748953620555969    0.5962310435917523    
-1.6677307685118707    1.6475809798433472    0.8635630357973535    -1.794106867032129    0.23576724690928239    1.9345586718254242    1.8665220736111652    1.715231095424259    1.4448153663136947    1.4585220061056003    -2.097657471713302    
0.8605510379359859    0.48221398085417627    1.5176826373865975    1.4652552486449435    1.9094578768378816    1.1144707218150902    0.4891850304975143    -1.6217012198757983    -0.26648664353939455    -0.702859436768092    1.0351022938433367    
Weight of Layer 4
-0.911096181634767    1.393613461284606    -0.9330396913369214    1.2364172665419595    0.6539246160388238    -0.3497594712315348    -0.5272926339150141    1.0073562856426537    -0.7754136627565675    0.3978221698601255    0.6516969484538829    
-2.1313935565863322    0.6870222803829747    -0.14063545929924332    -1.4601798330750633    -0.5046337368523596    0.45490880803140493    -0.3469665791558201    -1.1242340473155688    -1.2723993607026778    0.7754297084802044    -0.1971882092105515    
1.268461391063688    1.433232422744769    -1.9734642121928314    -2.1500226866603094    1.69187327087415    -0.5342565995220732    -1.8236939987229444    -0.9248308295424809    -1.0585137171567485    -0.758573013381397    -1.4786474341672335    
-1.3004208980147893    -1.4206386974340788    -1.83226719079787    1.853287649173723    -1.5346566916523345    0.18937676571029147    -2.14876104739136    0.19300765463829608    2.2600431704632133    -0.7439149441396848    -0.7944037931661944    
-1.5998484896496197    -1.6524100951400051    1.5947517659570918    -1.8662327423253926    1.2338013894973758    -0.4884517327249603    -1.933617967710128    -0.16207327398832927    -0.257515806279318    0.8147979296307275    1.3995976816521387    
2.094656544970861    -0.9941271469702547    1.6445550567163796    -1.8006734384410419    -1.639945317843356    -0.04008156577686328    -1.5983003403214098    -0.5203002571128433    1.7875581773282712    -1.094555900585581    1.2068765635018603    
2.1254252250165493    -0.32295734337741594    -1.3909813447797978    -1.7675398403329456    1.6196489153696365    -0.11330208718956442    1.2249494342821745    -0.9623282852038381    0.5949871990921731    -0.4589253834864904    -1.4480879152384845    
0.41124565810833846    1.8266387733496516    -1.3444906678350586    -1.8466017258629779    -1.2710822759712612    -2.3672244544192775    0.07985138355524748    1.1928505759997003    0.1224150977985233    1.581079240096574    -1.800780284328034    
-1.7595274297258634    1.2703227203108252    -0.01664878904783711    -1.9795940886734285    -0.020392614773247077    -1.4314141516158432    -1.365137154825855    1.7302923882870662    1.9823859978980145    0.35232814451148275    0.7343215278791788    
1.394419951767305    1.2499547753082167    -1.549641575886935    1.848772251833023    0.7361855983730334    0.6310928126046181    -0.8813463668969193    0.004308048034432659    0.43321638933450207    0.8087966273251945    0.07110982269880414    
Weight of Layer 5
0.03585680860332078    0.6094562888567525    1.7968463081634347    -2.362627715032082    2.2247821225164652    -1.0784288939947677    -1.0554498524378448    0.5861411371363056    -1.3689382763820177    -1.6272403702710627    -1.6503549168843508    
1.6301987233118784    -0.8906914047579433    0.24243168770601023    0.4009515829010596    -1.0758568810272509    -0.9051235220484805    -2.2014662058001826    -0.6016562255004753    -1.54618907737507    0.3068858681819345    -0.1910939351954038    
0.3949377293208745    -0.7652271919004981    0.68090033725971    1.2348269143656605    2.197797374061151    0.7456474083783481    2.177221715481275    0.577448303135589    0.6713302440403498    -1.422241156275792    0.3923309252775803    
2.016732930847877    0.9072966194060744    -1.173786606850799    0.762874680679405    0.5785929523331224    -0.2517270024395546    2.0525009570621475    1.3299906196120428    -0.3016789963343337    1.6433222480576049    1.4658027315448252    
-0.7093708542273217    -0.363654080609567    0.14670807608588535    1.2229445344521144    2.0365363421196743    -0.025435674952313806    1.1537986276254326    -1.2324297702242806    0.7761473466711113    0.8799485068219668    -0.5873930067918902    
0.3139747558740749    -1.6573144697633098    0.7038102951541025    -1.408818539999227    2.097157257533922    -0.7036366036514073    0.4160486916023455    0.8262172799352652    -1.4795358417499833    0.2852056896956041    -1.542169273346858    
-1.3692080951184145    -0.18564381183893783    1.4773933766691916    1.566187371091047    2.2303361972935196    1.6867117590655034    -2.2562477027382437    -0.7074433661402227    0.31697668962943404    -0.7387985710568243    -1.1533917617505614    
-1.2255743400186403    -1.0127411060516087    -1.3756205847124954    1.930937272879095    0.5512007768312437    -1.8860525843110458    1.83432047092595    1.7499230942835498    -0.05470238124314854    0.1415405841710963    0.5347734456158572    
0.8685622790833061    1.0117880568953437    -1.0680283034993974    -0.6423950104042628    2.0957313900176207    -0.3292735667051877    0.4115339082100468    0.2448817017887727    -0.36690487429065827    1.0946609803320706    -1.2972731428065445    
0.929738769296319    -0.8483315095032794    0.9886368647914796    -1.1490945738647198    0.48817906098502184    1.201937687948849    -1.8405795878382836    1.6127096671527423    -2.0480015245423417    -0.9757299992342688    0.5211781810863436    
Weight of Layer 6
-1.1548299180301753    -1.6001306147116388    -2.387282014077577    -1.082677370520492    -0.013943138965433734    0.10533899958501511    0.5742412321742517    -1.5014155245560539    0.8057997937824102    1.8479652037781695    -0.23508934192649694    

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 目錄 · 概況 · 原理 · 資源調度器分類 · YARN架構 · ResourceManager · NodeManager · ApplicationMaster · Container · YARN工作流程 · YARN資源調度 · 操作 · Overview · User Commands ...
  • 目錄 · 概況 · 原理 · HDFS 架構 · 塊 · NameNode · SecondaryNameNode · fsimage與edits合併 · DataNode · 數據讀寫 · 容錯機制 · 數據完整性 · NameNode HA · NameNode Federation · HDF ...
  • 1. mysql是一種常用的資料庫管理軟體,優點有:免費,開源,跨平臺,本文只是介紹一下MySQL的簡單操作 2.資料庫的基本結構 可以把資料庫理解成一個文件夾,資料庫中的數據存放的單位是表,可以理解為excel表格,表格的表頭稱為欄位,表中的每一條數據稱為記錄 3.MySQL安裝 1.從官網下載  ...
  • SQLite doesn't support high concurrency. In case of a lot of concurrent access from multi-process or multi-thread, calling a SQLite r/w function is pr ...
  • 一、視圖的定義 視圖也稱為虛表,視圖本身不占用物理存儲空間,視圖存放於數據字典中,簡單的來說視圖可以看做是sql語句的集合。視圖從資料庫中的表產生,這些表稱為視圖的基表,一個視圖可以從另一個視圖中產生。 視圖看上去非常象資料庫的物理表,對它的操作同任何其它的表一樣。當通過視圖修改數據時,實際上是在改 ...
  • 本文介紹了MySQL Cluster的概念和架構,並通過幾個實例詳細討論了Cluster的配置方法,啟動關閉,常用維護方法的概念。 ...
  • 關於Apache Spark "Why Apache Spark" "關於Apache Spark" "如何安裝Apache Spark" " Apache Spark的工作原理" "spark彈性分散式數據集" "RDD持久性" "spark共用變數" "Spark SQL" "Spark Str ...
  • 前言 最近在一次面試中,討論了一個這樣的問題:主鍵和索引有什麼區別?當時我的回答是這樣的:“主鍵就是加了唯一性約束的聚集索引。” “你確定你所說的是對的?” 面試官反問到。 “應該是對的。” 我不加思索地回答道。 “你回去後研究一下這個問題吧。” 難道我真的錯了? 第一次嘗試 當問題出現時,請用事實 ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...