【问题标题】:Validation Accuracy and training accuracy not improving after applying Transfer learning应用迁移学习后验证准确度和训练准确度没有提高
【发布时间】:2022-01-12 16:56:43
【问题描述】:

我正在开展一个项目,我正在尝试实施迁移学习来分类 ECG 信号(一维)。我有一个准确度很高的预训练模型,但是该模型是在不同的数据集上训练的,该数据集的输入形状为 (4096,12),输出形状为 (6)。我想在输入形状为 (350,5) 的数据上微调这个预训练模型。 为此,我在预训练模型的输入之前添加了一些层以获得形状 (4096,12),并添加了形状为 (5) 的输出密集层。我的模型代码如下:

from tensorflow.keras.layers import Dense,Input,Conv1D, BatchNormalization, 
Activation,Flatten,Reshape,Dropout
from tensorflow.keras.models import Model
#layer to get the desired shape for pre-trained model
new_inp = Input(shape=(300,5))
net = Flatten()(new_inp)
net = Dense(1000, activation='relu')(net)
net = Dropout(0.3)(net)
net = Dense(4096, activation='relu')(net)
net = Dropout(0.3)(net)
net = Reshape([4096,1])(net)
net = Conv1D (filters = 64, kernel_size = 11, strides = 1, padding = 'same')(net)
net = BatchNormalization()(net)
net = Activation('relu')(net)
net = Conv1D (filters = 12, kernel_size = 9, strides = 1, padding = 'same')(net)
net = BatchNormalization()(net)
net = Activation('relu')(net)
# pre-trained model
net = mod(net)
# output layer
ll = Dense(4,activation="softmax")(net)
newModel = Model(new_inp, ll)

我的训练和验证准确率没有提高...提高了 55%。关于这个问题的任何想法。

谢谢。

【问题讨论】:

标签: python tensorflow transfer-learning pre-trained-model conv1d


【解决方案1】:

迁移学习背后的理念是将新的可训练层连接到预训练模型的末端,冻结预训练的层,然后训练新的层。当您将这些新层添加到预训练模型的开始并训练整个网络时,您实际上是在覆盖预训练的系数。

可以在开头添加预处理层(或任何不需要反向传播的层),但您已经添加了整个 DNN。

【讨论】:

  • 我同意你的看法。但我在模型的开头添加图层只是为了获得所需的输入形状。训练后的模型使用 shape = (4096,12) 进行训练。但我的输入是(250,10)。那么我可以将我的输入提供给训练好的模型吗?
猜你喜欢
  • 2020-02-28
  • 2021-07-22
  • 2020-07-08
  • 2017-12-21
  • 1970-01-01
  • 2017-10-14
  • 1970-01-01
  • 2020-10-16
  • 2020-03-29
相关资源
最近更新 更多