เทนเซอร์โฟลว์:: ปฏิบัติการ:: ขยายDims

#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 ออก

ข้อโต้แย้ง:

  • ขอบเขต: วัตถุ ขอบเขต
  • แกน: 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

เอาท์พุท

::tensorflow::Output output

งานสาธารณะ

ขยายDims

 ExpandDims(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input axis
)

โหนด

::tensorflow::Node * node() const 

ตัวดำเนินการ::tensorflow::อินพุต

 operator::tensorflow::Input() const 

ตัวดำเนินการ::tensorflow::เอาต์พุต

 operator::tensorflow::Output() const