Interpreting get_weights() output?

5,849 views
Skip to first unread message

cle...@gmail.com

unread,
Jan 24, 2016, 12:20:15 AM1/24/16
to Keras-users
I'm trying to implement Olden's algorithm (a variant of Garson's algorithm) for determining input importance, and I'm having trouble interpreting the output of get_weights().  I have a simple Sequential network with 65 input nodes (64+1 constant nod to act as bias), 16 hidden nodes, and 3 output nodes. 

However, when I run model.layers[0].get_weights, I get /two/ arrays.  A 65 entry array made up of 16 values ( a 65x16 matrix, which I'm expecting).. but I also get a separate 16x1 array.  What is this?  Am I supposed to combine these two in some way to get the full input->hidden weight matrix?  Is this an internal hidden layer bias node weight(s) that I don't know about?

help() is not very helpful here:

Help on method get_weights in module keras.layers.core:

get_weights(self) method of keras.layers.core.Dense instance
    Return the weights of the layer,
    as a list of numpy arrays.

Any insights would be appreciated.  Thanks,
john.c

João Felipe Santos

unread,
Jan 24, 2016, 9:35:15 AM1/24/16
to Keras-users
A Dense layer performs the following operation: h = Wx + b. The first output is the weight matrix W and the second output is the bias vector b. You do not need to add a bias input (this is handled automatically by the Dense layer).

John Clemens

unread,
Jan 24, 2016, 11:07:38 AM1/24/16
to Keras-users
Ahh, so those are the layer's bias terms.  Thank you, that makes sense.

benoit...@gmail.com

unread,
Jan 15, 2017, 3:06:26 PM1/15/17
to Keras-users
Is this documented anywhere? I mean how each layer type uses weights?


On Sunday, January 24, 2016 at 9:35:15 AM UTC-5, João Felipe Santos wrote:

Klemen Grm

unread,
Jan 16, 2017, 4:18:10 AM1/16/17
to Keras-users, benoit...@gmail.com
If you're interested in the operation of keras at such a low level, the code is the documentation.

chja...@gmail.com

unread,
Oct 10, 2017, 2:36:27 AM10/10/17
to Keras-users
Hello,
In fact, I am trying to implement olden algorithm to get the variable importance in neural network. As Garson’s algorithm is interpreted in percentage and if you calculate all the values of explanatory variables that is equal to 100%. Now I was trying to do with Olden algorithm. Could you please help me that any value that is obtained in olden algorithm, how it is interpreted? For instance, I get X1=0.5 so what does that mean? Moreover, is there any threshold i.e. that X1 got 0.5 and X2 got 0.2 out of may be 100 etc. 

Best Regards

Javid
Reply all
Reply to author
Forward
0 new messages