【问题标题】:3D tensor input to embedding layer in keras or tensorflow?3D张量输入到keras或tensorflow中的嵌入层?
【发布时间】:2016-11-29 02:24:29
【问题描述】:

我想建立一个网络,将句子作为输入来预测情绪。所以我的输入看起来像(样本数 x 句子数 x 单词数)。然后我想在嵌入层中输入它来学习单词向量,然后将其相加得到句子向量。这种类型的架构在 keras 中是否可行?还是张量流?从文档中,Keras 的嵌入层只接受输入(nb_samples,sequence_length)。有什么办法可以解决吗?

【问题讨论】:

    标签: python tensorflow keras


    【解决方案1】:

    我猜这个类可以解析 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,)
    

    【讨论】:

      猜你喜欢
      • 2019-04-23
      • 1970-01-01
      • 2017-07-15
      • 2019-07-31
      • 2021-07-20
      • 1970-01-01
      • 2020-04-17
      • 1970-01-01
      • 2019-11-13
      相关资源
      最近更新 更多