Deep belief Network

Source: Internet
Author: User

Deep belief Network
3 Example
3.1 Test data
Follow the previous example data, or create a new image recognition data.

3.2 DBN Instances
Example 2 (reading a fixed sample: From the classical optimization algorithm test function sphere Model) ***********//

2 Reading Sample Data

Logger.getRootLogger.setLevel (Level.warn)

Valdata_path = "/user/huangmeiling/deeplearn/data1"

Valexamples (Data_path). Cache ()

Valtrain_d1 {line =

Valf1 = Line.split ("\ t")

Valf (f => 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 map (f = (f._2, f._3))

valopts = Array (100.0,20.0,0.0)

3 Set up training parameters, establish DBN model

Valdbnmodel =new DBN ().

SetSize (Array (5, 7)).

Setlayer (2).

Setmomentum (0.1).

Setalpha (1.0).

Dbntrain (Train_d, opts)

4 DBN Model converted to NN model

Valmynn dbnunfoldtonn (1)

valnnopts = Array (100.0,50.0,0.0)

Valnumexamples =train_d.count ()

println (S "Numexamples $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 rows-1) {

For (J <-0 totmpw1.cols-1) {

Print (TMPW1 (i,j) + "\ T")


println ()


Valnnmodel =new neuralnet ().

SetSize (mynn._1).

Setlayer (mynn._2).

Setactivation_function ("Sigm").

Setoutput_function ("Sigm").

SETINITW (Mynn._3).

Nntrain (Train_d, nnopts)

5 NN model test

Valnnforecast (Train_d)

Valnnerror =nnmodel.loss (Nnforecast)

println (S "nnerror = $NNerror.")

VALPRINTF1 (f = ( (0), (0)). Take (200)

PRINTLN ("forecast result--Actual value: Predicted value: Error")

for (i <-0 untilprintf1.length)

println (PRINTF1 (i). _1 + "\ T" +PRINTF1 (i). _2 + "\ T" + (PRINTF1 (i). _2-PRINTF1 (i). _1))

Deep belief Network

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

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.