เทนเซอร์โฟลว์:: ปฏิบัติการ:: ความลึกสู่อวกาศ

#include <array_ops.h>

DepthToSpace สำหรับเทนเซอร์ประเภท T

สรุป

จัดเรียงข้อมูลจากความลึกลงในบล็อกข้อมูลเชิงพื้นที่ นี่คือการเปลี่ยนแปลงแบบย้อนกลับของ SpaceToDepth โดยเฉพาะอย่างยิ่ง สหกรณ์นี้จะส่งออกสำเนาของเทนเซอร์อินพุตโดยที่ค่าจากมิติ depth ถูกย้ายในบล็อกเชิงพื้นที่ไปยังมิติ height และ width attr block_size ระบุขนาดบล็อกอินพุตและวิธีการย้ายข้อมูล

  • ชิ้นข้อมูลขนาด block_size * block_size จากความลึกจะถูกจัดเรียงใหม่เป็นบล็อกขนาด block_size x block_size ที่ไม่ทับซ้อนกัน
  • ความกว้างของเทนเซอร์เอาท์พุตคือ input_depth * block_size ในขณะที่ความสูงคือ input_height * block_size
  • พิกัด Y, X ภายในแต่ละบล็อกของภาพที่ส่งออกจะถูกกำหนดโดยองค์ประกอบลำดับสูงของดัชนีช่องสัญญาณเข้า
  • ความลึกของเทนเซอร์อินพุตจะต้องหารด้วย block_size * block_size

data_format attr ระบุเค้าโครงของเทนเซอร์อินพุตและเอาท์พุตด้วยตัวเลือกต่อไปนี้: "NHWC": [ batch, height, width, channels ] "NCHW": [ batch, channels, height, width ] "NCHW_VECT_C": qint8 [ batch, channels / 4, height, width, 4 ]

การพิจารณาการดำเนินการเป็นการแปลง เทนเซอร์ 6-D จะเป็นประโยชน์ เช่น สำหรับ data_format = NHWC แต่ละองค์ประกอบในเทนเซอร์อินพุตสามารถระบุได้ผ่าน 6 พิกัด เรียงลำดับโดยการลดความสำคัญเค้าโครงหน่วยความจำเป็น: n,iY,iX,bY,bX,oC (โดยที่ n=ดัชนีแบทช์, iX, iY หมายถึง X หรือพิกัด Y ภายในรูปภาพอินพุต, bX, bY หมายถึงพิกัดภายในบล็อกเอาต์พุต, oC หมายถึงช่องสัญญาณเอาท์พุต) เอาต์พุตจะเป็นอินพุตที่ถูกย้ายไปยังโครงร่างต่อไปนี้: n,iY,bY,iX,bX,oC

การดำเนินการนี้มีประโยชน์สำหรับการปรับขนาดการเปิดใช้งานระหว่างการโนโวลูชั่น (แต่เก็บข้อมูลทั้งหมด) เช่น แทนที่จะรวมกลุ่ม นอกจากนี้ยังมีประโยชน์สำหรับการฝึกโมเดลแบบ Convolutional เพียงอย่างเดียวอีกด้วย

ตัวอย่างเช่น เมื่อป้อนข้อมูลรูปร่าง [1, 1, 1, 4] , data_format = "NHWC" และ block_size = 2:

x = [[[[1, 2, 3, 4]]]]

  

This operation will output a tensor of shape [1, 2, 2, 1]:

   [[[[1], [2]],
     [[3], [4]]]]

ที่นี่ อินพุตมีแบทช์ 1 และแต่ละองค์ประกอบแบทช์มีรูปร่าง [1, 1, 4] เอาต์พุตที่เกี่ยวข้องจะมีองค์ประกอบ 2x2 และจะมีความลึก 1 ช่อง (1 = 4 / (block_size * block_size) ) รูปร่างองค์ประกอบเอาต์พุตคือ [2, 2, 1]

สำหรับเทนเซอร์อินพุตที่มีความลึกมากขึ้น รูปร่างของที่นี่ [1, 1, 1, 12] เช่น

x = [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]

การดำเนินการนี้ สำหรับขนาดบล็อก 2 จะส่งคืนเทนเซอร์ของรูปร่างต่อไปนี้ [1, 2, 2, 3]

   [[[[1, 2, 3], [4, 5, 6]],
     [[7, 8, 9], [10, 11, 12]]]]

  

Similarly, for the following input of shape [1 2 2 4], and a block size of 2:

x =  [[[[1, 2, 3, 4],
       [5, 6, 7, 8]],
      [[9, 10, 11, 12],
       [13, 14, 15, 16]]]]

ตัวดำเนินการจะส่งคืนเทนเซอร์ของรูปร่างต่อไปนี้ [1 4 4 1] :

x = [[[ [1],   [2],  [5],  [6]],
      [ [3],   [4],  [7],  [8]],
      [ [9],  [10], [13],  [14]],
      [ [11], [12], [15],  [16]]]]

  

Arguments:

  • scope: A Scope object
  • block_size: The size of the spatial block, same as in Space2Depth.

Returns:

Constructors and Destructors

DepthToSpace(const ::tensorflow::Scope & scope, ::tensorflow::Input input, int64 block_size)
DepthToSpace(const ::tensorflow::Scope & scope, ::tensorflow::Input input, int64 block_size, const DepthToSpace::Attrs & attrs)

Public attributes

operation
output

Public functions

node() const
::tensorflow::Node *
operator::tensorflow::Input() const
operator::tensorflow::Output() const

Public static functions

DataFormat(StringPiece x)

Structs

tensorflow::ops::DepthToSpace::Attrs

Optional attribute setters for DepthToSpace.

Public attributes

operation

Operation operation

เอาท์พุท

::tensorflow::Output output

งานสาธารณะ

ความลึกสู่อวกาศ

 DepthToSpace(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  int64 block_size
)

ความลึกสู่อวกาศ

 DepthToSpace(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  int64 block_size,
  const DepthToSpace::Attrs & attrs
)

โหนด

::tensorflow::Node * node() const 

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

 operator::tensorflow::Input() const 

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

 operator::tensorflow::Output() const 

ฟังก์ชันคงที่สาธารณะ

รูปแบบข้อมูล

Attrs DataFormat(
  StringPiece x
)