相关疑难解决方法(0)

在 Keras 中为多标签文本分类神经网络创建一个带有注意力的 LSTM 层

问候亲爱的社区成员。我正在创建一个神经网络来预测多标签 y。具体来说,神经网络接受 5 个输入(演员列表、情节摘要、电影特色、电影评论、片名)并尝试预测电影类型的顺序。在神经网络中,我使用了嵌入层和全局最大池化层。

然而,我最近发现了带有注意力的循环层,这是当今机器学习翻译中一个非常有趣的话题。所以,我想知道是否可以使用这些层之一,但只能使用 Plot Summary 输入。请注意,我不做 ml 翻译,而是做文本分类。

我的神经网络处于当前状态

def create_fit_keras_model(hparams,
                           version_data_control,
                           optimizer_name,
                           validation_method,
                           callbacks,
                           optimizer_version = None):

    sentenceLength_actors = X_train_seq_actors.shape[1]
    vocab_size_frequent_words_actors = len(actors_tokenizer.word_index)

    sentenceLength_plot = X_train_seq_plot.shape[1]
    vocab_size_frequent_words_plot = len(plot_tokenizer.word_index)

    sentenceLength_features = X_train_seq_features.shape[1]
    vocab_size_frequent_words_features = len(features_tokenizer.word_index)

    sentenceLength_reviews = X_train_seq_reviews.shape[1]
    vocab_size_frequent_words_reviews = len(reviews_tokenizer.word_index)

    sentenceLength_title = X_train_seq_title.shape[1]
    vocab_size_frequent_words_title = len(title_tokenizer.word_index)

    model = keras.Sequential(name='{0}_{1}dim_{2}batchsize_{3}lr_{4}decaymultiplier_{5}'.format(sequential_model_name, 
                                                                                                str(hparams[HP_EMBEDDING_DIM]), 
                                                                                                str(hparams[HP_HIDDEN_UNITS]),
                                                                                                str(hparams[HP_LEARNING_RATE]), 
                                                                                                str(hparams[HP_DECAY_STEPS_MULTIPLIER]),
                                                                                                version_data_control))
    actors = keras.Input(shape=(sentenceLength_actors,), name='actors_input')
    plot = keras.Input(shape=(sentenceLength_plot,), batch_size=hparams[HP_HIDDEN_UNITS], name='plot_input')
    features = keras.Input(shape=(sentenceLength_features,), name='features_input')
    reviews = keras.Input(shape=(sentenceLength_reviews,), name='reviews_input')
    title = keras.Input(shape=(sentenceLength_title,), name='title_input')

    emb1 …
Run Code Online (Sandbox Code Playgroud)

python machine-learning neural-network keras tensorflow

2
推荐指数
1
解决办法
3975
查看次数