[英]Autoencoder and Inception Resnet V2 feature
I want to create an autoencoder starting from the vector of the features extracted with the Inception Resnet V2 model and following the diagram shown in the following image:我想从使用 Inception Resnet V2 模型提取的特征向量开始创建一个自动编码器,并遵循下图所示的图表:
This is the code I wrote at the moment:这是我现在写的代码:
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)
What is the way to implement this in Keras?在 Keras 中实现这一点的方法是什么? Thank you for your time.
感谢您的时间。
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())
On a side note, I highly doubt that this autoencoder could work with such a small bottleneck, so I'd increase it from 2 to some larger value (maybe 100).附带说明一下,我非常怀疑这个自动编码器能否处理这么小的瓶颈,所以我会将它从 2 增加到更大的值(可能是 100)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.