tf.one_hot 实例

来源:互联网 发布:吉他班一般多少钱知乎 编辑:程序博客网 时间:2024/06/07 03:32

Examples
=========

Suppose that


indices = [0, 2, -1, 1]
depth = 3
on_value = 5.0
off_value = 0.0
axis = -1

Then output is [4 x 3]:


output =
[5.0 0.0 0.0]
[0.0 0.0 5.0]
[0.0 0.0 0.0]
[0.0 5.0 0.0]

Suppose that


indices = [[0, 2], [1, -1]]
depth = 3
on_value = 1.0
off_value = 0.0
axis = -1

Then output is [2 x 2 x 3]:


output =
[
[1.0, 0.0, 0.0]
[0.0, 0.0, 1.0]
][
[0.0, 1.0, 0.0]
[0.0, 0.0, 0.0]
]

Using default values for on_value and off_value:


indices = [0, 1, 2]
depth = 3

The output will be


output =
[[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]]

原创粉丝点击