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-D (скаляр). Указывает индекс измерения, в котором нужно расширить форму
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 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.3/api_docs/cc/class/tensorflow/ops/expand-dims