代码在 给一个拥抱 上
网络结构
inp = Input(shape=(maxlen,))
x = Embedding(max_features, embed_size)(inp)
x = Bidirectional(CuDNNGRU(64, return_sequences=True))(x)
x = GlobalMaxPool1D()(x)
x = Dense(16, activation="relu")(x)
x = Dropout(0.1)(x)
x = Dense(1, activation="sigmoid")(x)
model = Model(inputs=inp, outputs=x)
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=[auc])
print(model.summary())
Layer (type) | Output Shape | Param # |
---|---|---|
input_1 (InputLayer) | (None, 70) | 0 |
embedding_1 (Embedding) | (None, 70, 300) | 28500000 |
bidirectional_1 (Bidirectional) | (None, 70, 128) | 140544 |
global_max_pooling1d_1(GlobalMaxPool1D) | (None, 128) | 0 |
dense_1 (Dense) | (None, 16) | 2064 |
dropout_1 (Dropout) | (None, 16) | 0 |
dense_2 (Dense) | (None, 1) | 17 |
Total params | 28,642,625 | |
Trainable params | 28,642,625 | |
Non-trainable params | 0 |