Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::ops::BroadcastTo
#include <array_ops.h>
Broadcast an array for a compatible shape.
Summary
Broadcasting 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 to a shape, it starts with the trailing dimensions, and works its way forward.
For example,
>>> x = tf.constant([1, 2, 3])
>>> y = tf.broadcast_to(x, [3, 3])
>>> sess.run(y)
array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3]], dtype=int32)
In the above example, the input Tensor with the shape of [1, 3]
is broadcasted to output Tensor with shape of [3, 3]
.
Arguments:
- scope: A Scope object
- input: A Tensor to broadcast.
- shape: An 1-D
int
Tensor. The shape of the desired output.
Returns:
Public attributes
Public functions
node
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Output
operator::tensorflow::Output() const
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-04-20 UTC.
[null,null,["Last updated 2020-04-20 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/r1.15/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\n\n```gdscript\n\u003e\u003e\u003e x = tf.constant([1, 2, 3])\n\u003e\u003e\u003e y = tf.broadcast_to(x, [3, 3])\n\u003e\u003e\u003e sess.run(y)\narray([[1, 2, 3],\n [1, 2, 3],\n [1, 2, 3]], dtype=int32)\n```\n\n\u003cbr /\u003e\n\nIn the above example, the input [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with the shape of `[1, 3]` is broadcasted to output [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) with shape of `[3, 3]`.\n\nArguments:\n\n- scope: A [Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: A [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) to broadcast.\n- shape: An 1-D `int`[Tensor](/versions/r1.15/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/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): A [Tensor](/versions/r1.15/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/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, ::`[tensorflow::Input](/versions/r1.15/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/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_broadcast_to_1aaa451e1fc17fe438aa744a2880efca62) | `::`[tensorflow::Output](/versions/r1.15/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```"]]