ChrisArmstrong
ChrisArmstrong

Reputation: 2521

Extra weight values in neural network (nnet for R package)

I'm attempting to reverse engineer in Excel how the nnet package works using some simple input data. Here's the steps I've taken

  1. Import dummy data:test <- read.csv('dataScaled.csv',header=TRUE,sep = ",")

  2. Train the network: anntrain <- nnet(Price ~ Sqft + Bedrooms + Bathrooms,test[1:650,],size=2, maxit=5000,linout=TRUE)

  3. Grab the weights of the ANN: anntrain$wts This outputs:

    [1] -2.12443010 6.68900321 0.85338018 -0.73329823 -3.95336239 7.91917321 [7] -5.38893137 4.05941771 -0.02062346 0.26584364 0.32881035

  4. Grab fitted values of trained network: anntrain$fitted.values This outputs what I believe to be the scaled Price predictions of the trained network for each of the 650 transactions I trained it on above.

  5. Prove out the fitted values by recalculating using the above weights using the sigmoid function.

My confusion is that it outputs 11 weight values. If I only have 3 inputs, 2 hidden nodes and 1 output, shouldn't that equate to only 8 weights? What are the 3 extra weights for?

Upvotes: 3

Views: 1064

Answers (1)

alfa
alfa

Reputation: 3088

There is a bias in every layer (Why use a bias/threshold?). A bias is like a node that always gives you the input 1. Thus you have (3+1)*2+(2+1)*1 = 11 weights.

Upvotes: 1

Related Questions