如果是函数式模型,则可以直接输出 # import keras # from keras.models import Model # from keras.callbacks import ModelCheckpoint,Callback # import numpy as np # from keras.layers import Input,Conv2D,MaxPooling2D # import cv2 # # image = cv2.imread("D:\\machineTest\\falali.jpg") # print(image.shape) # cv2.imshow("1",image) # # # 第一层conv # image = image.reshape([-1, 386, 580, 3]) # img_input = Input(shape=(386, 580, 3)) # x = Conv2D(64, (3, 3), activation='relu', padding='same', name='block1_conv1')(img_input) # x = Conv2D(64, (3, 3), activation='relu', padding='same', name='block1_conv2')(x) # x = MaxPooling2D((2, 2), strides=(2, 2), name='block1_pool')(x) # model = Model(inputs=img_input, outputs=x) # out = model.predict(image) # print(out.shape) # out = out.reshape(193, 290,64) # image_conv1 = out[:,:,1].reshape(193, 290) # image_conv2 = out[:,:,20].reshape(193, 290) # image_conv3 = out[:,:,40].reshape(193, 290) # image_conv4 = out[:,:,60].reshape(193, 290) # cv2.imshow("conv1",image_conv1) # cv2.imshow("conv2",image_conv2) # cv2.imshow("conv3",image_conv3) # cv2.imshow("conv4",image_conv4) # cv2.waitKey(0)