Code Monkey home page Code Monkey logo

Comments (3)

SaiLoong avatar SaiLoong commented on May 20, 2024

我也有这样的疑惑,我一开始以为是经优化过后的公式,但是好像推不出来,而且我测试了两种结果并不一致

from reclearn.

liupandatacs avatar liupandatacs commented on May 20, 2024

这个代码我理解是不同特征相同领域向量相加,然后再进行不同领域之间交叉,和公式上的不太一样呢

from reclearn.

TangJiakai avatar TangJiakai commented on May 20, 2024

在求教二阶交叉信息的时候,embedding_lookup之后应该是一个batch,filed_num,field_num,k的矩阵, 后面做交叉之前为什么要做这一步的reduce_sum latent_vector = tf.reduce_sum(tf.nn.embedding_lookup(self.v, inputs), axis=1)

我理解的代码应该是这样的:

latent_vector = tf.nn.embedding_lookup(self.v, inputs) # (batch_size, field_num, field_num, k)
for i in range(self.field_num):
    for j in range(i+1, self.field_num):
        second_order += tf.reduce_sum(latent_vector[:, i, j] * latent_vector[:, j, i], axis=1, keepdims=True)

我也是这里感觉不是很好理解,我看过其他代码实现:首先将每个feat映射到filed(但是这里作者应该是简化了,一个feat就当作是一个filed了),然后循环应该是按照feat走,而不是按照filed,实际取的时候需要注意到对方feat所在filed,然后对应取embedding。包括你写的和作者的循环都是以range(self.filed_num)走的,所以似乎都不太对。

from reclearn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.