1. 磐创AI-开放猫官方网站首页
  2. 机器学习
  3. TensorFlow

tf.nn.embedding_lookup TensorFlow embedding_lookup 函数最简单实例

tf.nn.embedding_lookup TensorFlow embedding_lookup 函数最简单实例

#!/usr/bin/env python
# -*- coding: utf-8 -*-


import tensorflow as tf

import numpy as np

params=np.random.normal(loc=0.0,scale=1.0,size=[10,10])

ids=[1,2,3]

with tf.Session() as sess:
    print(sess.run(tf.nn.embedding_lookup(params,ids)))

输出:

[[ 1.7063815  -0.01654651 -0.64545987 -0.34758673  0.48317762  0.61799378
   0.23066604  1.70424801 -0.96460893  1.46270563]
 [ 0.54778326 -0.43954697 -0.3599735  -0.90806082 -0.73178132 -0.87372115
  -0.36002708  0.18508744 -0.01786275  0.87135015]
 [ 0.07694426 -1.55872459 -0.63802347 -1.5762184  -0.65273981 -1.62801055
   0.08332559  1.03982988 -0.96005845  0.17954909]]

原创文章,作者:fendouai,如若转载,请注明出处:https://panchuang.net/2017/08/04/tf-nn-embedding_lookup-tensorflow-embedding_lookup-demo/

发表评论

登录后才能评论

联系我们

400-800-8888

在线咨询:点击这里给我发消息

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息