I have a simple neural network, I need to get weights and biases from the model. I have tried a few approaches discussed before but I keep getting the out of bounds value error. Not sure how to fix this, or what I'm missing.
Network-
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(128, activation=tf.nn.relu),
keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.layers[0].get_weights()[1]
Error -
IndexError: list index out of range
This is what has been mentioned in a few questions,but I end up getting the out of bounds error for this.
I have another question, the index followed aftermodel.layers[], does it correspond to the layer?
For instance model.layers[1] gives the weights corresponding to the second layer, something like that?