【问题标题】:tf.contrib.layers.embedding_column from tensor flow来自张量流的 tf.contrib.layers.embedding_column
【发布时间】:2016-08-06 20:58:10
【问题描述】:

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

tf.contrib.layers.embedding_column

我想知道它是否使用 word2vec 或其他任何东西,或者我的想法完全错误。我试图在 GibHub 上四处点击,但一无所获。我猜想在 GitHub 上查找并不容易,因为 python 可能会引用一些 C++ 库。有人能指出我正确的方向吗?

【问题讨论】:

    标签: python tensorflow embedding


    【解决方案1】:

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

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

    通常,在进行嵌入时,您会采用数据的一些任意向量表示(例如 one-hot 向量),然后将其乘以表示嵌入的矩阵。这个矩阵可以通过 PCA 或在训练时通过 t-SNE 或 word2vec 等工具找到。

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

     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)
    

    据我所知,嵌入似乎是通过将您正在使用的任何学习规则(梯度下降等)应用于嵌入矩阵而形成的。

    【讨论】:

      【解决方案2】:

      我对嵌入也有类似的疑问。

      这里是重点:

      添加嵌入层以及传统的宽线性模型的能力可以通过将稀疏维度降低到低维度来实现准确的预测。

      这是一个关于它的good post

      这是一个simple example 组合嵌入层。使用 Titanic Kaggle 数据来预测乘客是否会根据某些属性(例如姓名、性别、他们持有的机票、他们支付的舱位票价等)来预测乘客是否能幸存。

      【讨论】:

        猜你喜欢
        • 2020-03-28
        • 1970-01-01
        • 1970-01-01
        • 2017-11-05
        • 2018-04-29
        • 2018-11-17
        • 1970-01-01
        • 2017-12-01
        • 2019-08-02
        相关资源
        最近更新 更多