Keras, How to get the output of each layer?

后端 未结 10 1951
借酒劲吻你
借酒劲吻你 2020-11-22 07:34

I have trained a binary classification model with CNN, and here is my code

model = Sequential()
model.add(Convolution2D(nb_filters, kernel_size[0], kernel_si         


        
10条回答
  •  日久生厌
    2020-11-22 07:54

    Following looks very simple to me:

    model.layers[idx].output
    

    Above is a tensor object, so you can modify it using operations that can be applied to a tensor object.

    For example, to get the shape model.layers[idx].output.get_shape()

    idx is the index of the layer and you can find it from model.summary()

提交回复
热议问题