Deep Belief Network

來源:互聯網
上載者:User

標籤:

Deep Belief Network
3執行個體
3.1 測試資料
按照上例資料,或者建立圖片識別資料。

3.2 DBN執行個體
//****************例2(讀取固定樣本:來源於經典最佳化演算法測試函數Sphere Model)***********//

//2 讀取樣本資料

Logger.getRootLogger.setLevel(Level.WARN)

valdata_path ="/user/huangmeiling/deeplearn/data1"

valexamples =www.ycyc66.cn/ sc.textFile(data_path).cache()

valtrain_d1 =www.zhenlyule.cn examples.map { line =>

valf1 = line.split("\t")

valf =f1.map(f =>www.egouyuLe.cn f.toDouble)

valid =f(0)

valy = Array(f(1))

valx =f.slice(2,f.length)

(id, new BDM(1,y.length,y),new BDM(1,x.length,x))

}

valtrain_d =train_d1.www.zhenloyl88.cn map(f => (f._2, f._3))

valopts = Array(100.0,20.0,0.0)

//3 設定訓練參數,建立DBN模型

valDBNmodel =new DBN().

setSize(Array(5, 7)).

setLayer(2).

setMomentum(0.1).

setAlpha(1.0).

DBNtrain(train_d, opts)

//4 DBN模型轉化為NN模型

valmynn =DBNmodel.www.yghrcp88.cn dbnunfoldtonn(1)

valnnopts = Array(100.0,50.0,0.0)

valnumExamples =train_d.count()

println(s"numExamples =www.huacairen88.cn $numExamples.")

println(mynn._2)

for (i <-0 tomynn._1.length -1) {

print(mynn._1(i) +"\t")

}

println()

println("mynn_W1")

valtmpw1 =mynn._3(0)

for (i <-0 totmpw1www.jyz521.com/ .rows -1) {

for (j <-0 totmpw1.cols -1) {

print(tmpw1(i,j) +"\t")

}

println()

}

valNNmodel =new www.ludingyule66.cn NeuralNet().

setSize(mynn._1).

setLayer(mynn._2).

setActivation_function("sigm").

setOutput_function("sigm").

setInitW(mynn._3).

NNtrain(train_d, nnopts)

//5 NN模型測試

valNNforecast =NNmodel.www.yyzx66.cn/ predict(train_d)

valNNerror =NNmodel.Loss(NNforecast)

println(s"NNerror = $NNerror.")

valprintf1 =NNforecast.map(f => (www.myqunliphoto.com/ f.label.data(0), f.predict_label.data(0))).take(200)

println("預測結果——實際值:預測值:誤差")

for (i <-0 untilprintf1.length)

println(printf1(i)._1 +"\t" +printf1(i)._2 +"\t" + (printf1(i)._2 -printf1(i)._1))

Deep Belief Network

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.