'how to print all parameters of a keras model
I am trying to print all the 1290 parameters in dense_1 layer, but model.get_weights()[7] only show 10 parameters.
How could I print all the 1290 parameters of dense_1 layer?
What is the difference between model.get_weights() and model.layer.get_weights()
>model.get_weights()[7]
array([-2.8552295e-04, -4.3254648e-03, -1.8752701e-04, 2.3482188e-03,
-3.4848123e-04, 7.6121779e-04, -2.7494309e-06, -1.9068648e-03,
6.0777756e-04, 1.9550985e-03], dtype=float32)
>model.summary()
Model: "sequential"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
conv2d (Conv2D) (None, 26, 26, 32) 320
conv2d_1 (Conv2D) (None, 24, 24, 64) 18496
max_pooling2d (MaxPooling2D (None, 12, 12, 64) 0
)
dropout (Dropout) (None, 12, 12, 64) 0
flatten (Flatten) (None, 9216) 0
dense (Dense) (None, 128) 1179776
dropout_1 (Dropout) (None, 128) 0
dense_1 (Dense) (None, 10) 1290
_________________________________________________________________
=================================================================
Total params: 1,199,882
Trainable params: 1,199,882
Non-trainable params: 0
_________________________________________________________________
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
