dòng chảy căng:: ôi:: OneHot
#include <array_ops.h>
Trả về một tenxơ một nóng.
Bản tóm tắt
Các vị trí được biểu thị bằng chỉ mục trong indices
lấy giá trị on_value
, trong khi tất cả các vị trí khác lấy giá trị off_value
.
Nếu indices
đầu vào là hạng N
thì đầu ra sẽ có hạng N+1
, Trục mới được tạo ở axis
thứ nguyên (mặc định: trục mới được thêm vào cuối).
Nếu indices
là vô hướng thì hình dạng đầu ra sẽ là một vectơ có độ dài depth
.
Nếu indices
là một vectơ có độ dài features
, thì hình dạng đầu ra sẽ là:
features x depth if axis == -1
depth x features if axis == 0
Nếu indices
là một ma trận (lô) có hình dạng [batch, features]
thì hình dạng đầu ra sẽ là:
batch x features x depth if axis == -1
batch x depth x features if axis == 1
depth x batch x features if axis == 0
Ví dụ
Giả sử rằng
indices = [0, 2, -1, 1]
depth = 3
on_value = 5.0
off_value = 0.0
axis = -1
Sau đó đầu ra là [4 x 3]
:
output =
[5.0 0.0 0.0] // one_hot(0)
[0.0 0.0 5.0] // one_hot(2)
[0.0 0.0 0.0] // one_hot(-1)
[0.0 5.0 0.0] // one_hot(1)
Giả sử rằng
indices = [0, 2, -1, 1]
depth = 3
on_value = 0.0
off_value = 3.0
axis = 0
Sau đó đầu ra là [3 x 4]
:
output =
[0.0 3.0 3.0 3.0]
[3.0 3.0 3.0 0.0]
[3.0 3.0 3.0 3.0]
[3.0 0.0 3.0 3.0]
// ^ one_hot(0)
// ^ one_hot(2)
// ^ one_hot(-1)
// ^ one_hot(1)
Giả sử rằng
indices = [[0, 2], [1, -1]]
depth = 3
on_value = 1.0
off_value = 0.0
axis = -1
Sau đó đầu ra là [2 x 2 x 3]
:
output =
[
[1.0, 0.0, 0.0] // one_hot(0)
[0.0, 0.0, 1.0] // one_hot(2)
][
[0.0, 1.0, 0.0] // one_hot(1)
[0.0, 0.0, 0.0] // one_hot(-1)
]
Lập luận:
- phạm vi: Một đối tượng Phạm vi
- chỉ số: Một tensor của chỉ số.
- chiều sâu: Một đại lượng vô hướng xác định độ sâu của một chiều nóng.
- on_value: Một đại lượng vô hướng xác định giá trị cần điền vào đầu ra khiindex
indices[j] = i
. - off_value: Một đại lượng vô hướng xác định giá trị cần điền vào đầu ra khiindex
indices[j] != i
.
Thuộc tính tùy chọn (xem Attrs
):
- trục: Trục cần điền (mặc định: -1, trục trong cùng mới).
Trả về:
-
Output
: Tensor một nóng.
Hàm tạo và hàm hủy | |
---|---|
OneHot (const :: tensorflow::Scope & scope, :: tensorflow::Input indices, :: tensorflow::Input depth, :: tensorflow::Input on_value, :: tensorflow::Input off_value) | |
OneHot (const :: tensorflow::Scope & scope, :: tensorflow::Input indices, :: tensorflow::Input depth, :: tensorflow::Input on_value, :: tensorflow::Input off_value, const OneHot::Attrs & attrs) |
Chức năng công cộng | |
---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const |
Cấu trúc | |
---|---|
tenorflow:: ops:: OneHot:: Attrs | Bộ cài đặt thuộc tính tùy chọn cho OneHot . |
Thuộc tính công khai
hoạt động
Operation operation
đầu ra
::tensorflow::Output output
Chức năng công cộng
OneHot
OneHot(
const ::tensorflow::Scope & scope,
::tensorflow::Input indices,
::tensorflow::Input depth,
::tensorflow::Input on_value,
::tensorflow::Input off_value
)
OneHot
OneHot(
const ::tensorflow::Scope & scope,
::tensorflow::Input indices,
::tensorflow::Input depth,
::tensorflow::Input on_value,
::tensorflow::Input off_value,
const OneHot::Attrs & attrs
)
nút
::tensorflow::Node * node() const
toán tử::tenorflow::Đầu vào
operator::tensorflow::Input() const
toán tử::tenorflow::Đầu ra
operator::tensorflow::Output() const
Các hàm tĩnh công khai
Trục
Attrs Axis(
int64 x
)