【问题标题】:Autoencoder and Inception Resnet V2 feature自动编码器和 Inception Resnet V2 功能
【发布时间】:2021-10-03 08:00:39
【问题描述】:

我想从使用 Inception Resnet V2 模型提取的特征向量开始创建一个自动编码器,并遵循下图所示的图表:

这是我此刻写的代码:

image_size = (150, 150, 3)

model = InceptionResNetV2(weights='imagenet', include_top=False, input_shape=image_size)   
    
for layer in model.layers:
    layer.trainable = False

feature = model.predict(x[:10])

print(feature.shape) # (10, 3, 3, 1536)

在 Keras 中实现这一点的方法是什么?感谢您的宝贵时间。

【问题讨论】:

    标签: python tensorflow keras autoencoder


    【解决方案1】:
    from tensorflow.keras.layers import Input, Dense
    from tensorflow.keras.models import Model
    
    inputs = Input(1536)
    x = inputs
    x = Dense(500, activation='relu')(x)
    x = Dense(2, activation='relu')(x)
    x = Dense(500, activation='relu')(x)
    x = Dense(1536, activation='relu')(x)
    full_model = Model(inputs, x)
    print(full_model.summary())
    

    顺便说一句,我非常怀疑这个自动编码器能否在如此小的瓶颈下工作,所以我将它从 2 增加到更大的值(可能是 100)。

    【讨论】:

    • 这样我得到了 InputLayer(输入:[(None, 150, 150, 3)],输出:[(None, 150, 150, 3)])。相反,我必须得到:InputLayer(输入:[(None,1536)],输出:[(None,1536)])。实际上,在输入中,它必须采用提取特征向量的维度。您能否更正您的代码,以便您对答案进行正面评价?谢谢。
    • 缺少指令 x = inputs。感谢您的宝贵时间,请为以后的读者添加上一条说明。
    猜你喜欢
    • 2018-11-08
    • 2018-02-07
    • 2017-02-06
    • 2017-05-15
    • 2018-08-02
    • 1970-01-01
    • 2020-01-06
    • 2018-05-31
    • 2017-11-10
    相关资源
    最近更新 更多