Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
aliran tensor:: operasi:: Mengisi
#include <array_ops.h>
Membuat tensor yang diisi dengan nilai skalar.
Ringkasan
Operasi ini membuat tensor bentuk dims
dan mengisinya dengan value
.
Misalnya:
# Output tensor has shape [2, 3].
fill([2, 3], 9) ==> [[9, 9, 9]
[9, 9, 9]]
tf.fill
berbeda dari tf.constant
dalam beberapa hal:
-
tf.fill
hanya mendukung konten skalar, sedangkan tf.constant
mendukung nilai Tensor . -
tf.fill
membuat Op dalam grafik komputasi yang membuat nilai Tensor aktual saat runtime. Hal ini berbeda dengan tf.constant
yang menyematkan seluruh Tensor ke dalam grafik dengan node Const
. - Karena
tf.fill
mengevaluasi pada waktu proses grafik, ia mendukung bentuk dinamis berdasarkan Tensor waktu proses lainnya, tidak seperti tf.constant
.
Argumen:
- ruang lingkup: Objek Lingkup
- meredupkan: 1-D. Mewakili bentuk tensor keluaran.
- nilai: 0-D (skalar). Nilai untuk mengisi tensor yang dikembalikan.
(numpy) Setara dengan np.full
Pengembalian:
Atribut publik
Fungsi publik
simpul
::tensorflow::Node * node() const
operator::tensorflow::Input() const
operator::tensorflow::Keluaran
operator::tensorflow::Output() const
Kecuali dinyatakan lain, konten di halaman ini dilisensikan berdasarkan Lisensi Creative Commons Attribution 4.0, sedangkan contoh kode dilisensikan berdasarkan Lisensi Apache 2.0. Untuk mengetahui informasi selengkapnya, lihat Kebijakan Situs Google Developers. Java adalah merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-26 UTC.
[null,null,["Terakhir diperbarui pada 2025-07-26 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/r1.15/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/r1.15/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/r1.15/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\nArguments:\n\n- scope: A [Scope](/versions/r1.15/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/r1.15/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/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)` dims, ::`[tensorflow::Input](/versions/r1.15/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/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_fill_1af59efc826ad951c4bb994ccf186b0e3c) | `::`[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_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```"]]