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 ออก
ข้อโต้แย้ง:
- ขอบเขต: วัตถุ ขอบเขต
- แกน: 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
เอาต์พุต
::tensorflow::Output output
หน้าที่สาธารณะ
ขยายมิติ
ExpandDims( const ::tensorflow::Scope & scope, ::tensorflow::Input input, ::tensorflow::Input axis )
โหนด
::tensorflow::Node * node() const
ตัวดำเนินการ::เทนเซอร์โฟลว์::อินพุต
operator::tensorflow::Input() const
ตัวดำเนินการ::เทนเซอร์โฟลว์::เอาต์พุต
operator::tensorflow::Output() const