print(model.layers[312].output)
输出 (None,2048)
第312层代码
Dense(2048, activation='relu',name='first_dense')
样本数量为8732。我需要第一个密集层(first_dense)的输出形状为(8732,2048)。换句话说,我需要这一层在所有样本上的结果。如何实现?
提前感谢!!
回答:
你可以创建一个子模型并进行预测
new_model = Model(model.input, model.layers[312].output)new_model.predict(...)