首页 文章

3D张量输入到keras或tensorflow中的嵌入层?

提问于
浏览
1

我想 Build 一个网络,以句子作为输入来预测情绪 . 所以我的输入看起来像(样本数量x句子数量x字数) . 然后我想在嵌入层中提供这个以学习单词向量,然后可以将它们相加以得到句子向量 . 在keras中这种架构是否可行?还是Tensorflow?从文档中,Keras的嵌入层只接受输入(nb_samples,sequence_length) . 有可能进行任何工作吗?

1 回答

  • 2

    我想这课程为Keras解决了:

    class AnyShapeEmbedding(Embedding):
        '''
        This Embedding works with inputs of any number of dimensions.
        This can be accomplished by simply changing the output shape computation.
        '''
        #@overrides
        def compute_output_shape(self, input_shape):
            return input_shape + (self.output_dim,)
    

相关问题