Keras 模型看起来像这样
inp = Input(shape=(maxlen, ))
x = Embedding(max_features, embed_size, weights=[embedding_matrix], trainable=False)(inp)
x = SpatialDropout1D(dropout)(x)
x = Bidirectional(LSTM(num_filters, return_sequences=True))(x)
max_pool = GlobalMaxPooling1D()(x)
x = concatenate([x_h, max_pool])
outp = Dense(6, activation="sigmoid")(x)
根据文档,输出形状=输入形状,即(样本、时间步长、通道)
问题
- SpatialDropout1D() 对 Embedding() 的输出真正做了什么?我知道 LSTM Embedding 的输出是维度(batch_size、steps、features)。
- SpatialDropout1D() 是否只是将每个单词的一些单词嵌入值随机替换为 0?
- SpatialDropout1D() 与 Keras 中的 Dropout() 有何不同?