此代码来自https://www.kaggle.com/dkaraflos/1-geomean-nn-and-6featlgbm-2-259-private-lb,本次比赛的目标是利用地震信号来预测实验室的时间地震。这个环节的人在4000多个团队中获得了第一名
def get_model():
inp = Input(shape=(1,train_sample.shape[1]))
x = BatchNormalization()(inp)
x = LSTM(128,return_sequences=True)(x) # LSTM as first layer performed better than Dense.
x = Convolution1D(128, (2),activation='relu', padding="same")(x)
x = Convolution1D(84, (2),activation='relu', padding="same")(x)
x = Convolution1D(64, (2),activation='relu', padding="same")(x)
x = Flatten()(x)
x = Dense(64, activation="relu")(x)
x = Dense(32, activation="relu")(x)
#outputs
ttf = Dense(1, activation='relu',name='regressor')(x) # Time to Failure
tsf = Dense(1)(x) # Time Since Failure
classifier = Dense(1, activation='sigmoid')(x) # Binary for TTF<0.5 seconds
model = models.Model(inputs=inp, outputs=[ttf,tsf,classifier])
opt = optimizers.Nadam(lr=0.008)
# We are fitting to 3 targets simultaneously: Time to Failure (TTF), Time Since Failure (TSF), and Binary for TTF<0.5 seconds
# We weight the model to optimize heavily for TTF
# Optimizing for TSF and Binary TTF<0.5 helps to reduce overfitting, and helps for generalization.
model.compile(optimizer=opt, loss=['mae','mae','binary_crossentropy'],loss_weights=[8,1,1],metrics=['mae'])
return model
不过,根据我的推导,我认为x = Convolution1D(128, (2),activation='relu', padding="same")(x)
和x = Dense(128, activation='relu ')(x)
具有相同的效果,因为卷积核以时间步长为1对序列进行卷积。原则上,它与全连接层非常相似。为什么这里使用conv1D而不是直接使用全连接层呢?我的推导有错误吗?
拉莫斯之舞
相关分类