one_hot实验
#!/usr/bin/env python# encoding: utf-8'''@author: lele Ye@contact: 1750112338@qq.com@software: pycharm 2018.2@file: 02one_hot实验.py@time: 2018/9/8 21:59@desc:'''import tensorflow as tfCLASS...
·
#!/usr/bin/env python
# encoding: utf-8
'''
@author: lele Ye
@contact: 1750112338@qq.com
@software: pycharm 2018.2
@file: 02one_hot实验.py
@time: 2018/9/8 21:59
@desc:
'''
import tensorflow as tf
CLASS = 8
label = [x for x in range(8)]
labels = tf.convert_to_tensor(label)
one_hot_labels = tf.one_hot(indices=labels,depth=CLASS,on_value=1,off_value=0)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
print("before one-hot:",sess.run(labels))
print("after one-hot:\n", sess.run(one_hot_labels))
更多推荐
已为社区贡献18条内容
所有评论(0)