我使用Resnet3D训练了一个模型,我想提取一个层的神经元。我计划将它们与SVM分类器一起使用。如何提取这些权重并将其放入numpy数组?
通过keras加载权重
model = Resnet3DBuilder.build_resnet_18((128, 96, 96, 3), nClass[0])
model.load_weights('drive/app/models/3d_resnet_modelq.hdf5')
提取一层
dns = model.layers[-1].output
现在我该怎么办?
If you just want to visualise the features, in pure Keras you can define a
Model
with the desired layer as output:Note that in order for this to work,
model
must have been compiled at least once.