จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
เทนเซอร์โฟลว์:: ปฏิบัติการ:: ออกอากาศถึง
#include <array_ops.h>
ออกอากาศอาร์เรย์สำหรับรูปร่างที่เข้ากันได้
สรุป
การแพร่ภาพคือกระบวนการสร้างอาร์เรย์ให้มีรูปร่างที่เข้ากันได้สำหรับการดำเนินการทางคณิตศาสตร์ รูปร่างสองแบบเข้ากันได้หากคู่มิติแต่ละคู่มีค่าเท่ากันหรือหนึ่งในนั้นคือหนึ่งเดียว เมื่อพยายามถ่ายทอด Tensor ไปยังรูปร่าง เทนเซอร์ จะเริ่มต้นด้วยมิติส่วนท้าย และดำเนินการไปข้างหน้า
ตัวอย่างเช่น,
x = tf.constant ([1, 2, 3]) y = tf.broadcast_to (x, [3, 3]) พิมพ์ (y) tf.Tensor ( [[1 2 3] [1 2 3] [1 2 3]], รูปร่าง=(3, 3), dtype=int32)
ในตัวอย่างข้างต้น อินพุต เทนเซอร์ ที่มีรูปร่างเป็น [1, 3]
จะถูกถ่ายทอดไปยังเอาท์พุต เทนเซอร์ ที่มีรูปร่างเป็น [3, 3]
เมื่อดำเนินการออกอากาศ เช่น การคูณเมตริกซ์ด้วยสเกลาร์ การออกอากาศ (โดยปกติ) จะให้ผลประโยชน์ด้านเวลาหรือพื้นที่ เนื่องจากเทนเซอร์ที่ออกอากาศไม่เคยเกิดขึ้นจริง
อย่างไรก็ตาม broadcast_to
ไม่ได้รับสิทธิประโยชน์ใดๆ ดังกล่าว เทนเซอร์ที่สร้างขึ้นใหม่ใช้หน่วยความจำเต็มรูปแบบของรูปร่างที่ออกอากาศ (ในบริบทของกราฟ broadcast_to
อาจถูกรวมเข้ากับการดำเนินการในภายหลัง จากนั้นจึงปรับให้เหมาะสมออกไป)
ข้อโต้แย้ง:
ผลตอบแทน:
คุณลักษณะสาธารณะ
งานสาธารณะ
โหนด
::tensorflow::Node * node() const
operator::tensorflow::Input() const
ตัวดำเนินการ::tensorflow::เอาต์พุต
operator::tensorflow::Output() const
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-26 UTC
[null,null,["อัปเดตล่าสุด 2025-07-26 UTC"],[],[],null,["# tensorflow::ops::BroadcastTo Class Reference\n\ntensorflow::ops::BroadcastTo\n============================\n\n`#include \u003carray_ops.h\u003e`\n\nBroadcast an array for a compatible shape.\n\nSummary\n-------\n\nBroadcasting is the process of making arrays to have compatible shapes for arithmetic operations. Two shapes are compatible if for each dimension pair they are either equal or one of them is one. When trying to broadcast a [Tensor](/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) to a shape, it starts with the trailing dimensions, and works its way forward.\n\nFor example,\n\nx = tf.constant(\\[1, 2, 3\\]) y = tf.broadcast_to(x, \\[3, 3\\]) print(y) tf.Tensor( \\[\\[1 2 3\\] \\[1 2 3\\] \\[1 2 3\\]\\], shape=(3, 3), dtype=int32)\n\nIn the above example, the input [Tensor](/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with the shape of `[1, 3]` is broadcasted to output [Tensor](/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with shape of `[3, 3]`.\n\nWhen doing broadcasted operations such as multiplying a tensor by a scalar, broadcasting (usually) confers some time or space benefit, as the broadcasted tensor is never materialized.\n\nHowever, `broadcast_to` does not carry with it any such benefits. The newly-created tensor takes the full memory of the broadcasted shape. (In a graph context, `broadcast_to` might be fused to subsequent operation and then be optimized away, however.)\n\nArguments:\n\n- scope: A [Scope](/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: A [Tensor](/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) to broadcast.\n- shape: An 1-D `int`[Tensor](/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor). The shape of the desired output.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): A [Tensor](/versions/r2.3/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor).\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [BroadcastTo](#classtensorflow_1_1ops_1_1_broadcast_to_1a37bf1f8b63e588def9b3805017209ee6)`(const ::`[tensorflow::Scope](/versions/r2.3/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, ::`[tensorflow::Input](/versions/r2.3/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` shape)` ||\n\n| ### Public attributes ||\n|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_broadcast_to_1abb152ff71cda1cf3af84a7c656faac03) | [Operation](/versions/r2.3/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_broadcast_to_1aaa451e1fc17fe438aa744a2880efca62) | `::`[tensorflow::Output](/versions/r2.3/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|------------------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_broadcast_to_1a2c429236acfd549d2252190a63a446f0)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_broadcast_to_1a21be2705c2eba98f1cf7560295561b58)`() const ` | ` ` ` ` |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_broadcast_to_1a43222f4482f5ccb868548380633ce7f5)`() const ` | ` ` ` ` |\n\nPublic attributes\n-----------------\n\n### operation\n\n```text\nOperation operation\n``` \n\n### output\n\n```text\n::tensorflow::Output output\n``` \n\nPublic functions\n----------------\n\n### BroadcastTo\n\n```gdscript\n BroadcastTo(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input shape\n)\n``` \n\n### node\n\n```gdscript\n::tensorflow::Node * node() const \n``` \n\n### operator::tensorflow::Input\n\n```gdscript\n operator::tensorflow::Input() const \n``` \n\n### operator::tensorflow::Output\n\n```gdscript\n operator::tensorflow::Output() const \n```"]]