Tensorflow获得特定的层激活功能

时间:2019-10-10 12:54:06

标签: tensorflow

我在使用VGG16架构的项目中使用转移学习。我想从VGG16的某些特定层(具体来说是Block3_Conv3,Block4_conv3,Block5_conv3)中提取特征,但是我不知道如何在Tensorflow中进行操作。我知道我应该以某种方式使用Session,因为它是在tensorflow中进行交互和传递数据的唯一方法,但是我不知道确切的方法。

我使用Keras API完成的操作如下:

 # Load and process image.
        image = load_img(imagePaths[i], target_size=(224, 224));
        image = img_to_array(image);
        image = np.expand_dims(image, axis=0);
        image = imagenet_utils.preprocess_input(image);
        # ---------------------------------------------------------

        # Extract features from block_3 conv_3
        features1 = block3_conv3.predict(image);

我在“ features1”中拥有我想要的功能,我该如何使用张量流和会话来做类似的事情?

0 个答案:

没有答案
相关问题