Extragerea unui kernel dintr-o rețea antrenată
O modalitate de a interpreta modelele este să examinezi proprietățile kernelurilor din straturile convoluționale. În acest exercițiu, vei extrage unul dintre kernelurile dintr-o rețea neuronală convoluțională ale cărei ponderi au fost salvate într-un fișier hdf5.
Acest exercițiu face parte din cursul
Modelarea imaginilor cu Keras
Instrucțiuni pentru exercițiu
- Încarcă ponderile în model din fișierul
weights.hdf5. - Obține primul strat convoluțional din model folosind atributul
layers. - Folosește metoda
.get_weights()pentru a extrage ponderile din acest strat.
Exercițiu interactiv practic
Încearcă acest exercițiu completând acest cod de exemplu.
# Load the weights into the model
model.____('weights.hdf5')
# Get the first convolutional layer from the model
c1 = model.____[0]
# Get the weights of the first convolutional layer
weights1 = c1.____()
# Pull out the first channel of the first kernel in the first layer
kernel = weights1[0][...,0, 0]
print(kernel)