tensorflow使用DenseNet201迁移学习

from tensorflow.keras.applications import DenseNet201
with strategy.scope():
    rnet = DenseNet201(
        input_shape=(IMAGE_SIZE[0], IMAGE_SIZE[1], 3),
        weights='imagenet',
        include_top=False
    )
    
    rnet.trainable = True

    model = tf.keras.Sequential([
        rnet,
        tf.keras.layers.GlobalAveragePooling2D(),
        tf.keras.layers.Dense(len(CLASSES), activation='softmax')
    ])
        
model.compile(
    optimizer='adam',
    loss = 'sparse_categorical_crossentropy',
    metrics=['sparse_categorical_accuracy']
)

model.summary()

models.append(model)
发布了60 篇原创文章 · 获赞 15 · 访问量 4059

猜你喜欢

转载自blog.csdn.net/qq_15557299/article/details/104290349
今日推荐