tensorflow::ops::OneHot
#include <array_ops.h>Trả về một tensor one-hot.
Bản tóm tắt
Các vị trí được biểu thị bằng chỉ số trong indices có giá trị on_value , trong khi tất cả các vị trí khác có giá trị off_value .
Nếu indices đầu vào có hạng N , đầu ra sẽ có hạng N+1 . Trục mới được tạo tại axis chiều (mặc định: trục mới được thêm vào cuối).
Nếu indices là một giá trị vô hướng, hình dạng đầu ra sẽ là một vectơ có độ dài là 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 (batch) 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
Khi đó, kết quả đầ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)
]Luận điểm:
- phạm vi: Một đối tượng Phạm vi
- chỉ số: Một tenxơ chỉ số.
- độ sâu: Một đại lượng vô hướng xác định độ sâu của chiều không gian một chiều.
- on_value: Một giá trị vô hướng xác định giá trị cần điền vào đầu ra khi
indices[j] = i. - off_value: Một giá trị vô hướng xác định giá trị cần điền vào đầu ra khi
indices[j] != i.
Các thuộc tính tùy chọn (xem Attrs ):
- trục: Trục cần tô màu (mặc định: -1, một trục trong cùng mới).
Trả về:
-
Output: Tensor one-hot.
Hàm khởi 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) |
Thuộc tính công khai | |
|---|---|
operation | |
output | |
Chức năng công cộng | |
|---|---|
node () const | ::tensorflow::Node * |
operator::tensorflow::Input () const | |
operator::tensorflow::Output () const | |
Các hàm tĩnh công khai | |
|---|---|
Axis (int64 x) | |
Cấu trúc | |
|---|---|
| tensorflow::ops::OneHot::Attrs | Các thiết lập 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
operator::tensorflow::Input
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Các hàm tĩnh công khai
Trục
Attrs Axis( int64 x )