จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เทนเซอร์โฟลว์:: ปฏิบัติการ:: ความลึกสู่อวกาศ
#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:
Public attributes
งานสาธารณะ
โหนด
::tensorflow::Node * node() const
operator::tensorflow::Input() const
ตัวดำเนินการ::tensorflow::เอาต์พุต
operator::tensorflow::Output() const
ฟังก์ชันคงที่สาธารณะ
Attrs DataFormat(
StringPiece x
)
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[null,null,["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# tensorflow::ops::DepthToSpace Class Reference\n\ntensorflow::ops::DepthToSpace\n=============================\n\n`#include \u003carray_ops.h\u003e`\n\n[DepthToSpace](/versions/r2.2/api_docs/cc/class/tensorflow/ops/depth-to-space#classtensorflow_1_1ops_1_1_depth_to_space) for tensors of type T.\n\nSummary\n-------\n\nRearranges data from depth into blocks of spatial data. This is the reverse transformation of SpaceToDepth. More specifically, this op outputs a copy of the input tensor where values from the `depth` dimension are moved in spatial blocks to the `height` and `width` dimensions. The attr `block_size` indicates the input block size and how the data is moved.\n\n\n- Chunks of data of size `block_size * block_size` from depth are rearranged into non-overlapping blocks of size `block_size x block_size`\n- The width the output tensor is `input_depth * block_size`, whereas the height is `input_height * block_size`.\n- The Y, X coordinates within each block of the output image are determined by the high order component of the input channel index.\n- The depth of the input tensor must be divisible by `block_size * block_size`.\n\n\u003cbr /\u003e\n\nThe `data_format` attr specifies the layout of the input and output tensors with the following options: \"NHWC\": `[ batch, height, width, channels ]` \"NCHW\": `[ batch, channels, height, width ]` \"NCHW_VECT_C\": `qint8 [ batch, channels / 4, height, width, 4 ]`\n\nIt is useful to consider the operation as transforming a 6-D [Tensor](/versions/r2.2/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). e.g. for data_format = NHWC, Each element in the input tensor can be specified via 6 coordinates, ordered by decreasing memory layout significance as: n,iY,iX,bY,bX,oC (where n=batch index, iX, iY means X or Y coordinates within the input image, bX, bY means coordinates within the output block, oC means output channels). The output would be the input transposed to the following layout: n,iY,bY,iX,bX,oC\n\nThis operation is useful for resizing the activations between convolutions (but keeping all data), e.g. instead of pooling. It is also useful for training purely convolutional models.\n\nFor example, given an input of shape `[1, 1, 1, 4]`, data_format = \"NHWC\" and block_size = 2:\n\n\n```text\nx = [[[[1, 2, 3, 4]]]]\n```\n\n\u003cbr /\u003e\n\n\n``````text\n \n This operation will output a tensor of shape `[1, 2, 2, 1]`:\n \n [[[[1], [2]],\n [[3], [4]]]]\n \n Here, the input has a batch of 1 and each batch element has shape `[1, 1, 4]`, the corresponding output will have 2x2 elements and will have a depth of 1 channel (1 = `4 / (block_size * block_size)`). The output element shape is `[2, 2, 1]`.\n For an input tensor with larger depth, here of shape `[1, 1, 1, 12]`, e.g.\n \n \n```text\nx = [[[[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]]]]\n```\n\n \n This operation, for block size of 2, will return the following tensor of shape `[1, 2, 2, 3]`\n \n \n```text\n [[[[1, 2, 3], [4, 5, 6]],\n [[7, 8, 9], [10, 11, 12]]]]\n```\n\n \n \n \n`````text\n \n Similarly, for the following input of shape `[1 2 2 4]`, and a block size of 2:\n \n x = [[[[1, 2, 3, 4],\n [5, 6, 7, 8]],\n [[9, 10, 11, 12],\n [13, 14, 15, 16]]]]\n \n the operator will return the following tensor of shape `[1 4 4 1]`:\n \n \n```text\nx = [[[ [1], [2], [5], [6]],\n [ [3], [4], [7], [8]],\n [ [9], [10], [13], [14]],\n [ [11], [12], [15], [16]]]]\n```\n\n \n \n \n````gdscript\n \n Arguments:\n \n- scope: A /versions/r2.2/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope object\n\n \n- block_size: The size of the spatial block, same as in Space2Depth.\n\n \n\n Returns:\n \n- /versions/r2.2/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output: The output tensor. \n\n \n\n \n\n\n \n### Constructors and Destructors\n\n\n \n\n\n\n #classtensorflow_1_1ops_1_1_depth_to_space_1a2c9e364eeb7f160468ea1d96f6cfb8e6(const ::/versions/r2.2/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, ::/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input, int64 block_size)\n \n\n \n\n\n\n #classtensorflow_1_1ops_1_1_depth_to_space_1a8f6fcb6f032b7cf643f973e6ac13c27c(const ::/versions/r2.2/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, ::/versions/r2.2/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input, int64 block_size, const /versions/r2.2/api_docs/cc/struct/tensorflow/ops/depth-to-space/attrs#structtensorflow_1_1ops_1_1_depth_to_space_1_1_attrs & attrs)\n \n\n \n\n\n \n\n\n \n### Public attributes\n\n\n \n\n\n\n #classtensorflow_1_1ops_1_1_depth_to_space_1a957382b910309c5111ee14e1ab67e743\n \n\n \n\n /versions/r2.2/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation\n \n\n \n\n\n\n #classtensorflow_1_1ops_1_1_depth_to_space_1af26b151763bb3a313233613cc17a77f0\n \n\n \n\n ::/versions/r2.2/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output\n \n\n \n\n\n \n\n\n \n### Public functions\n\n\n \n\n\n\n #classtensorflow_1_1ops_1_1_depth_to_space_1a41b9c51a62fa577cdd60303f1e4121ab() const \n \n\n \n\n ::tensorflow::Node *\n \n\n \n\n\n\n #classtensorflow_1_1ops_1_1_depth_to_space_1a0ef22b3a73050121df809b37a5bcf10c() const \n \n\n \n\n `\n` \n`\n` \n\n\n\n #classtensorflow_1_1ops_1_1_depth_to_space_1a20278953425786797aa70c161f3c746b() const \n \n\n \n\n `\n` \n`\n` \n\n\n \n\n\n \n### Public static functions\n\n\n \n\n\n\n #classtensorflow_1_1ops_1_1_depth_to_space_1abc5ed947752840207dff9d8be78c49a3(StringPiece x)\n \n\n \n\n /versions/r2.2/api_docs/cc/struct/tensorflow/ops/depth-to-space/attrs#structtensorflow_1_1ops_1_1_depth_to_space_1_1_attrs\n \n\n \n\n\n \n\n\n \n### Structs\n\n\n \n\n\n\n /versions/r2.2/api_docs/cc/struct/tensorflow/ops/depth-to-space/attrs\n \n\n \nOptional attribute setters for /versions/r2.2/api_docs/cc/class/tensorflow/ops/depth-to-space#classtensorflow_1_1ops_1_1_depth_to_space. \n\n \n\n\n Public attributes\n \n \n### operation\n\n\n \n```\nOperation operation\n```\n\n \n\n \n \n \n### output\n\n\n \n\n\n```text\n::tensorflow::Output output\n```\n\n \n\n \n Public functions\n \n \n### DepthToSpace\n\n\n \n\n\n```gdscript\n DepthToSpace(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n int64 block_size\n)\n```\n\n \n\n \n \n \n### DepthToSpace\n\n\n \n\n\n```gdscript\n DepthToSpace(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n int64 block_size,\n const DepthToSpace::Attrs & attrs\n)\n```\n\n \n\n \n \n \n### node\n\n\n \n\n\n```gdscript\n::tensorflow::Node * node() const \n```\n\n \n\n \n \n \n### operator::tensorflow::Input\n\n\n \n\n\n```gdscript\n operator::tensorflow::Input() const \n```\n\n \n\n \n \n \n### operator::tensorflow::Output\n\n\n \n\n\n```gdscript\n operator::tensorflow::Output() const \n```\n\n \n\n \n Public static functions\n \n \n### DataFormat\n\n\n \n\n\n```text\nAttrs DataFormat(\n StringPiece x\n)\n```\n\n \n\n \n\n \n\n \n````\n`````\n``````"]]