tensorflow 函数

tf.one_hot

import tensorflow as tf

classes = 3
labels = tf.constant([[0, 1, 2], [0, 1, 2]])
output = tf.one_hot(labels, classes)

sess = tf.Session()
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    output = sess.run(output)
    print("output of one-hot is : ", output)

tf.nn.embedding_lookup

import tensorflow as tf

p = tf.Variable(tf.random_normal([10, 3]))
b = tf.nn.embedding_lookup(p, [[1, 2], [2, 2]])
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print(sess.run(b))
    print(sess.run(p))


发布了19 篇原创文章 · 获赞 3 · 访问量 978
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览