2
我試圖獲得訓練網絡中圖層的值。我可以得到層作爲TensorFlow張量,但我無法訪問陣列狀的價值觀:Keras - 獲得訓練層的權重
from keras.models import load_model
model = load_model('./model.h5')
layer_dict = dict([(layer.name, layer) for layer in model.layers])
layer_name = 'block5_sepconv1_act'
filter_index = 0
layer_output = layer_dict['model_1'][layer_name].output
# <tf.Tensor 'block5_sepconv1_act/Relu:0' shape=(?, 16, 16, 728) dtype=float32>
layer_filter = layer_output[:, :, :, filter_index]
# <tf.Tensor 'strided_slice_11:0' shape=(?, 16, 16) dtype=float32>
# how do I get the 16x16 values ??
你想輸出值還是權重?他們不一樣。 –