T
- data type for output()
output@Operator public final class BroadcastTo<T> extends PrimitiveOp implements Operand<T>
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]`.operation
Modifier and Type | Method and Description |
---|---|
Output<T> |
asOutput()
Returns the symbolic handle of a tensor.
|
static <T,U extends Number> |
create(Scope scope,
Operand<T> input,
Operand<U> shape)
Factory method to create a class wrapping a new BroadcastTo operation.
|
Output<T> |
output()
A Tensor.
|
equals, hashCode, op, toString
public static <T,U extends Number> BroadcastTo<T> create(Scope scope, Operand<T> input, Operand<U> shape)
scope
- current scopeinput
- A Tensor to broadcast.shape
- An 1-D `int` Tensor. The shape of the desired output.public Output<T> asOutput()
Operand
Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.
asOutput
in interface Operand<T>
OperationBuilder.addInput(Output)
Copyright © 2022. All rights reserved.