tensorflow::ops::ExpandDims
#include <array_ops.h>
Вставляет измерение 1 в форму тензора.
Краткое описание
Данная операция принимает тензор input, и вставляет измерение 1 в индекс измерения axis формы тензора input. Индекс измерения axis начинается с нуля; если для axis указано отрицательное число, оно подсчитывается от конца.
Эта операция полезна, если требуется добавить размерность пакета к одиночному элементу. Например, если у вас есть один образ с формой [height, width, channels], вы можете преобразовать его в пакет из 1 образа с помощью expand_dims(image, 0), что изменит форму на [1, height, width, channels].
Другие примеры:
# 't' is a tensor of shape [2] shape(expand_dims(t, 0)) ==> [1, 2] shape(expand_dims(t, 1)) ==> [2, 1] shape(expand_dims(t, -1)) ==> [2, 1]
# 't2' is a tensor of shape [2, 3, 5] shape(expand_dims(t2, 0)) ==> [1, 2, 3, 5] shape(expand_dims(t2, 2)) ==> [2, 3, 1, 5] shape(expand_dims(t2, 3)) ==> [2, 3, 5, 1]
Для этой операции требуется:
-1-input.dims() <= dim <= input.dims()
Эта операция связана с squeeze(), которая удаляет измерения размером 1.
Аргументы:
- scope: Объект Scope
- axis: 0-мерный (скаляр). Указывает индекс измерения, в котором необходимо расширить форму
input. Должен быть в диапазоне[-rank(input) - 1, rank(input)].
Возвращает:
-
Output: Содержит те же данные, что иinput, но форма дополнена дополнительным измерением размером 1.
| Конструкторы и деструкторы | |
|---|---|
ExpandDims(const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input axis) |
| Публичные атрибуты | |
|---|---|
operation | |
output | |
| Публичные функции | |
|---|---|
node() const | ::tensorflow::Node * |
operator::tensorflow::Input() const | |
operator::tensorflow::Output() const | |
Публичные атрибуты
operation
Operation operation
output
::tensorflow::Output output
Публичные функции
ExpandDims
ExpandDims( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input axis )
node
::tensorflow::Node * node() const
operator::tensorflow::Input
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 4.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.4/api_docs/cc/class/tensorflow/ops/expand-dims