gpt4 book ai didi

python - 迁移学习 : model is giving unchanged loss results. 不是训练吗?

转载 作者:行者123 更新时间:2023-12-04 15:12:14 24 4
gpt4 key购买 nike

<分区>

我正在尝试在 Inception V3 上训练回归模型。输入是大小为 (96,320,3) 的图像。总共有 16k+ 图像,其中 12k+ 用于训练,其余用于验证。我已经卡住了 Inception 中的所有层,但解冻它们也无济于事(已经尝试过)。我已将预训练模型的顶部替换为以下代码中所示的几层。

X_train = preprocess_input(X_train)
inception = InceptionV3(weights='imagenet', include_top=False, input_shape=(299,299,3))
inception.trainable = False
print(inception.summary())

driving_input = Input(shape=(96,320,3))
resized_input = Lambda(lambda image: tf.image.resize(image,(299,299)))(driving_input)
inp = inception(resized_input)

x = GlobalAveragePooling2D()(inp)

x = Dense(512, activation = 'relu')(x)
x = Dense(256, activation = 'relu')(x)
x = Dropout(0.25)(x)
x = Dense(128, activation = 'relu')(x)
x = Dense(64, activation = 'relu')(x)
x = Dropout(0.25)(x)
result = Dense(1, activation = 'relu')(x)

lr_schedule = ExponentialDecay(initial_learning_rate=0.1, decay_steps=100000, decay_rate=0.95)
optimizer = Adam(learning_rate=lr_schedule)
loss = Huber(delta=0.5, reduction="auto", name="huber_loss")
model = Model(inputs = driving_input, outputs = result)
model.compile(optimizer=optimizer, loss=loss)

checkpoint = ModelCheckpoint(filepath="./ckpts/model.h5", monitor='val_loss', save_best_only=True)
stopper = EarlyStopping(monitor='val_loss', min_delta=0.0003, patience = 10)

batch_size = 32
epochs = 100

model.fit(x=X_train, y=y_train, shuffle=True, validation_split=0.2, epochs=epochs,
batch_size=batch_size, verbose=1, callbacks=[checkpoint, stopper])

这导致: enter image description here

为什么我的模型没有训练,我该如何解决?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com