我的模型的准确性比纸上的低

时间:2019-05-02 15:40:06

标签: keras nlp conv-neural-network

我正在尝试实施[yoon kim]“句子分类中的CNN”

https://arxiv.org/pdf/1408.5882.pdf

但是我的cnn_static模型的精度比它低得多

(大约76%,与cnn_rand模型没有显着差异)

我没有任何改善的想法

以下是我的代码和关于模型的图

def get_cnn_static(input_data, data_label, vocabulary, embedding_matrix) :
    num_sentence = input_data.shape[0] # #10662 for MR data set
    sequence_length = input_data.shape[1] #n 56 for MR data set
    num_classes = data_label.shape[1] #positve, negative 2 classes for MR data set
    vocab_size = len(vocabulary) +1 # 18769 for MR data set


    # model structure
    inputs = Input(batch_shape=(None,sequence_length), name ='Input_Layer')
    emb_layer = Embedding(vocab_size, emb_size, weights = [embedding_matrix], input_length=sequence_length, trainable=False, name='Embedding_Layer')(inputs)
    pooled_outputs = []
    for i in filter_size :
        convLayer = Conv1D(feature_map, i, strides=1, activation='relu', use_bias=True, kernel_initializer = 'TruncatedNormal')(emb_layer)            
        convLayer = MaxPooling1D(pool_size = sequence_length-i +1)(convLayer)            
        pooled_outputs.append(convLayer)
    merged = Concatenate()(pooled_outputs)
    flatten_layer = Flatten()(merged)
    dropout_layer = Dropout(p)(flatten_layer)
    predictions = Dense(num_classes, activation='softmax')(dropout_layer)
    model = Model(inputs=inputs, outputs=predictions)
    return model

plot_model

我已经检查了embedding_matrix。但这是正确制作的

有什么想法可以改善我的模型吗?

0 个答案:

没有答案