Stay organized with collections
Save and categorize content based on your preferences.
tensorflow::ops::Fill
#include <array_ops.h>
Creates a tensor filled with a scalar value.
Summary
This operation creates a tensor of shape dims
and fills it with value
.
For example:
# Output tensor has shape [2, 3].
fill([2, 3], 9) ==> [[9, 9, 9]
[9, 9, 9]]
tf.fill
differs from tf.constant
in a few ways:
tf.fill
only supports scalar contents, whereas tf.constant
supports Tensor values.
tf.fill
creates an Op in the computation graph that constructs the actual Tensor value at runtime. This is in contrast to tf.constant
which embeds the entire Tensor into the graph with a Const
node.
- Because
tf.fill
evaluates at graph runtime, it supports dynamic shapes based on other runtime Tensors, unlike tf.constant
.
Args:
- scope: A Scope object
- dims: 1-D. Represents the shape of the output tensor.
- value: 0-D (scalar). Value to fill the returned tensor.
(numpy) Equivalent to np.full
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. Some content is licensed under the numpy license.
Last updated 2023-10-06 UTC.
[null,null,["Last updated 2023-10-06 UTC."],[],[],null,["# tensorflow::ops::Fill Class Reference\n\ntensorflow::ops::Fill\n=====================\n\n`#include \u003carray_ops.h\u003e`\n\nCreates a tensor filled with a scalar value.\n\nSummary\n-------\n\nThis operation creates a tensor of shape `dims` and fills it with `value`.\n\nFor example:\n\n\n```text\n# Output tensor has shape [2, 3].\nfill([2, 3], 9) ==\u003e [[9, 9, 9]\n [9, 9, 9]]\n```\n\n\u003cbr /\u003e\n\n`tf.fill` differs from `tf.constant` in a few ways:\n\n\n- `tf.fill` only supports scalar contents, whereas `tf.constant` supports [Tensor](/versions/r2.14/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) values.\n- `tf.fill` creates an Op in the computation graph that constructs the actual [Tensor](/versions/r2.14/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) value at runtime. This is in contrast to `tf.constant` which embeds the entire [Tensor](/versions/r2.14/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) into the graph with a `Const` node.\n- Because `tf.fill` evaluates at graph runtime, it supports dynamic shapes based on other runtime Tensors, unlike `tf.constant`.\n\n\u003cbr /\u003e\n\nArgs:\n\n- scope: A [Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- dims: 1-D. Represents the shape of the output tensor.\n- value: 0-D (scalar). Value to fill the returned tensor.\n\n\u003cbr /\u003e\n\n(numpy) Equivalent to np.full\n\nReturns:\n\n- [Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output): The output tensor.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [Fill](#classtensorflow_1_1ops_1_1_fill_1a01c1c041aa66636af36c215a28cad8f8)`(const ::`[tensorflow::Scope](/versions/r2.14/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` dims, ::`[tensorflow::Input](/versions/r2.14/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` value)` ||\n\n| ### Public attributes ||\n|----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_fill_1ab58dad131aa0ced03a7b508cb5f17ee8) | [Operation](/versions/r2.14/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_fill_1af59efc826ad951c4bb994ccf186b0e3c) | `::`[tensorflow::Output](/versions/r2.14/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public functions ||\n|----------------------------------------------------------------------------------------------------------------|------------------------|\n| [node](#classtensorflow_1_1ops_1_1_fill_1a470a2e887eb44734252766d0f4759b04)`() const ` | `::tensorflow::Node *` |\n| [operator::tensorflow::Input](#classtensorflow_1_1ops_1_1_fill_1a7eb9e821e29fbfa81a25dd5ae382ce1f)`() const ` | |\n| [operator::tensorflow::Output](#classtensorflow_1_1ops_1_1_fill_1a952032189c0e55332094cc69e197ae06)`() 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### Fill\n\n```gdscript\n Fill(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input dims,\n ::tensorflow::Input value\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```"]]