【发布时间】:2016-11-29 02:24:29
【问题描述】:
我想建立一个网络,将句子作为输入来预测情绪。所以我的输入看起来像(样本数 x 句子数 x 单词数)。然后我想在嵌入层中输入它来学习单词向量,然后将其相加得到句子向量。这种类型的架构在 keras 中是否可行?还是张量流?从文档中,Keras 的嵌入层只接受输入(nb_samples,sequence_length)。有什么办法可以解决吗?
【问题讨论】:
标签: python tensorflow keras
我想建立一个网络,将句子作为输入来预测情绪。所以我的输入看起来像(样本数 x 句子数 x 单词数)。然后我想在嵌入层中输入它来学习单词向量,然后将其相加得到句子向量。这种类型的架构在 keras 中是否可行?还是张量流?从文档中,Keras 的嵌入层只接受输入(nb_samples,sequence_length)。有什么办法可以解决吗?
【问题讨论】:
标签: python tensorflow keras
我猜这个类可以解析 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,)
【讨论】: