tf.contrib.layers公司.从tens嵌入_列

2024-09-29 21:26:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在学习tensorflow教程tensorflow。我想找到以下行的描述:

tf.contrib.layers.embedding_column

我想知道它是否使用了word2vec或其他任何东西,或者我的思考方向完全错误。我试着在GibHub上点击,但什么也没找到。我猜想GITHUB的查找并不容易,因为Python可能引用一些C++库。谁能给我指出正确的方向吗?在


Tags: githublayerstftensorflow错误column教程word2vec
2条回答

我也一直在想这个。我不太清楚他们在做什么,但这是我发现的。在

paper on wide and deep learning中,它们将嵌入向量描述为随机初始化,然后在训练过程中进行调整以最小化误差。在

通常,在进行嵌入时,需要取数据的任意向量表示(例如一个热向量),然后将其乘以表示嵌入的矩阵。这个矩阵可以通过PCA找到,也可以通过t-SNE或word2vec这样的工具进行训练。在

嵌入列的实际代码是here,它被实现为一个名为_EmbeddingColumn的类,它是_FeatureColumn的子类。它将嵌入矩阵存储在其sparse_id_column属性中。然后,输入层的方法应用这个嵌入矩阵生成下一层的嵌入。在

 def to_dnn_input_layer(self,
                         input_tensor,
                         weight_collections=None,
                         trainable=True):
    output, embedding_weights = _create_embedding_lookup(
        input_tensor=self.sparse_id_column.id_tensor(input_tensor),
        weight_tensor=self.sparse_id_column.weight_tensor(input_tensor),
        vocab_size=self.length,
        dimension=self.dimension,
        weight_collections=_add_variable_collection(weight_collections),
        initializer=self.initializer,
        combiner=self.combiner,
        trainable=trainable)

据我所知,嵌入是通过对嵌入矩阵应用任何学习规则(梯度下降等)形成的。在

我对嵌入也有类似的怀疑。在

要点如下:

The ability of adding an embedding layer along with tradition wide linear models allows for accurate predictions by reducing sparse dimensionality down to low dimensionality.

enter image description here

这里有一个关于它的good post!在

这是一个结合嵌入层的simple example。利用泰坦尼克号的卡格尔数据,根据乘客的姓名、性别、拥有的机票、所付舱位的票价等属性来预测乘客是否能存活下来

相关问题 更多 >

    热门问题