【发布时间】: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