tensorflow--embedding_lookup 和 embedding_lookup_sparse
生活随笔
收集整理的這篇文章主要介紹了
tensorflow--embedding_lookup 和 embedding_lookup_sparse
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
tf.nn.embedding_lookup ( tensor, id )
作用:選取一個(gè)張量里面索引對(duì)應(yīng)的元素
應(yīng)用場(chǎng)景:單值離散特征的 embedding,相當(dāng)于 one-hot 編碼
| user1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 |
| user2 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| user3 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
tf.nn.embedding_lookup_sparse(params, sp_ids)
作用:選取一個(gè)張量里面多個(gè)索引對(duì)應(yīng)的元素的平均值
應(yīng)用場(chǎng)景:多值離散特征的 embedding,相當(dāng)于多次 one-hot 后取平均值
| user1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
| user2 | 1 | 0 | 0 | 1 | 0 | 0 | 0 |
| user3 | 0 | 0 | 0 | 0 | 1 | 1 | 1 |
比如 user1:( [ 0 1 2 ] + [ 3 4 5 ] + [ 6 7 8 ] ) / 3 = [ 3. , 4. , 5. ]
相關(guān)參考:推薦系統(tǒng)遇上深度學(xué)習(xí)(四)–多值離散特征的embedding解決方案
總結(jié)
以上是生活随笔為你收集整理的tensorflow--embedding_lookup 和 embedding_lookup_sparse的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Hadoop 安装目录及配置
- 下一篇: 【LeetCode】3月24日打卡-Da