Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
#include <ops.h>
Trình khởi tạo cho phép xây dựng một đối tượng Đầu vào từ nhiều loại hằng số C++ khác nhau, chẳng hạn như các hằng số nguyên thủy đơn giản và các danh sách trình khởi tạo lồng nhau biểu thị một mảng đa chiều.
Bản tóm tắt
Tất cả các hàm tạo của trình khởi tạo đều là các mẫu, do đó, các loại hằng số C++ đã nói ở trên có thể được sử dụng để xây dựng một Trình khởi tạo . Trình khởi tạo lưu trữ giá trị mà nó được tạo trong đối tượng Tensor .
Hàm tạo và hàm hủy |
---|
Initializer (const T & v)
Xây dựng từ một giá trị vô hướng của một kiểu số học hoặc một kiểu có thể chuyển đổi thành chuỗi (ví dụ: |
Initializer (const Tensor & t)
|
Initializer (const T & v, const TensorShape & shape)
Xây dựng từ một giá trị vô hướng và một hình dạng rõ ràng. |
Initializer (const std::initializer_list< T > & v)
Xây dựng từ danh sách khởi tạo của các đại lượng vô hướng (tenxơ một chiều). |
Initializer (const std::initializer_list< T > & v, const TensorShape & shape)
Xây dựng từ danh sách khởi tạo gồm các đại số vô hướng và một hình dạng rõ ràng. |
Initializer (const std::initializer_list< Initializer > & v)
Xây dựng một tenxơ đa chiều từ danh sách khởi tạo lồng nhau. |
Thuộc tính công khai
Chức năng công cộng
Trừ phi có lưu ý khác, nội dung của trang này được cấp phép theo Giấy phép ghi nhận tác giả 4.0 của Creative Commons và các mẫu mã lập trình được cấp phép theo Giấy phép Apache 2.0. Để biết thông tin chi tiết, vui lòng tham khảo Chính sách trang web của Google Developers. Java là nhãn hiệu đã đăng ký của Oracle và/hoặc các đơn vị liên kết với Oracle.
Cập nhật lần gần đây nhất: 2025-07-26 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-26 UTC."],[],[],null,["# tensorflow::Input::Initializer Struct Reference\n\ntensorflow::Input::Initializer\n==============================\n\n`#include \u003cops.h\u003e`\n\n[Initializer](/versions/r1.15/api_docs/cc/struct/tensorflow/input/initializer#structtensorflow_1_1_input_1_1_initializer) enables constructing an [Input](/versions/r1.15/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input) object from various kinds of C++ constants such as simple primitive constants and nested initializer lists representing a multi-dimensional array.\n\nSummary\n-------\n\n[Initializer](/versions/r1.15/api_docs/cc/struct/tensorflow/input/initializer#structtensorflow_1_1_input_1_1_initializer) constructors are all templates, so the aforementioned kinds of C++ constants can be used to construct an [Initializer](/versions/r1.15/api_docs/cc/struct/tensorflow/input/initializer#structtensorflow_1_1_input_1_1_initializer). [Initializer](/versions/r1.15/api_docs/cc/struct/tensorflow/input/initializer#structtensorflow_1_1_input_1_1_initializer) stores the value it got constructed with in a [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) object.\n\n| ### Constructors and Destructors ||\n|---|---|\n| [Initializer](#structtensorflow_1_1_input_1_1_initializer_1ade60a4fdcfa9a530604fbf39d3b5be12)`(const T & v)` Construct from a scalar value of an arithmetic type or a type that can be converted to a string (eg. ||\n| [Initializer](#structtensorflow_1_1_input_1_1_initializer_1a9314222b3303dcf97314a4bcbcaa94ad)`(const `[Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor)` & t)` ||\n| [Initializer](#structtensorflow_1_1_input_1_1_initializer_1ab77d0712180868a7311936ca9a034835)`(const T & v, const TensorShape & shape)` Construct from a scalar value and an explicit shape. ||\n| [Initializer](#structtensorflow_1_1_input_1_1_initializer_1a91bd52431434dc5358ae8aa39070fe5f)`(const std::initializer_list\u003c T \u003e & v)` Construct from a initializer list of scalars (a one-dimensional tensor). ||\n| [Initializer](#structtensorflow_1_1_input_1_1_initializer_1a3f572c2835a2310e2d5c28138e69ae76)`(const std::initializer_list\u003c T \u003e & v, const TensorShape & shape)` Construct from a initializer list of scalars and an explicit shape. ||\n| [Initializer](#structtensorflow_1_1_input_1_1_initializer_1a8099f954da757c77ac7d8e1c32df88ce)`(const std::initializer_list\u003c `[Initializer](/versions/r1.15/api_docs/cc/struct/tensorflow/input/initializer#structtensorflow_1_1_input_1_1_initializer)` \u003e & v)` Construct a multi-dimensional tensor from a nested initializer list. ||\n\n| ### Public attributes ||\n|------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------|\n| [status](#structtensorflow_1_1_input_1_1_initializer_1af0ab9526e575fd7d4b9d5f7dbabcb7e4) | [Status](/versions/r1.15/api_docs/cc/class/tensorflow/status#classtensorflow_1_1_status) |\n| [tensor](#structtensorflow_1_1_input_1_1_initializer_1a7b520438780dc80f0162a480a3cadb74) | [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor) |\n\n| ### Public functions ||\n|-----------------------------------------------------------------------------------------------------|---------------|\n| [AsTensorProto](#structtensorflow_1_1_input_1_1_initializer_1a6b1e360b983fec2140b756971fe7699d)`()` | `TensorProto` |\n\nPublic attributes\n-----------------\n\n### status\n\n```text\nStatus tensorflow::Input::Initializer::status\n``` \n\n### tensor\n\n```text\nTensor tensorflow::Input::Initializer::tensor\n``` \n\nPublic functions\n----------------\n\n### AsTensorProto\n\n```text\nTensorProto tensorflow::Input::Initializer::AsTensorProto()\n``` \n\n### Initializer\n\n```gdscript\n tensorflow::Input::Initializer::Initializer(\n const T & v\n)\n``` \nConstruct from a scalar value of an arithmetic type or a type that can be converted to a string (eg.\n\na string literal). \n\n### Initializer\n\n```gdscript\n tensorflow::Input::Initializer::Initializer(\n const Tensor & t\n)\n``` \n\n### Initializer\n\n```gdscript\n tensorflow::Input::Initializer::Initializer(\n const T & v,\n const TensorShape & shape\n)\n``` \nConstruct from a scalar value and an explicit shape. \n\n### Initializer\n\n```gdscript\n tensorflow::Input::Initializer::Initializer(\n const std::initializer_list\u003c T \u003e & v\n)\n``` \nConstruct from a initializer list of scalars (a one-dimensional tensor). \n\n### Initializer\n\n```gdscript\n tensorflow::Input::Initializer::Initializer(\n const std::initializer_list\u003c T \u003e & v,\n const TensorShape & shape\n)\n``` \nConstruct from a initializer list of scalars and an explicit shape. \n\n### Initializer\n\n```gdscript\n tensorflow::Input::Initializer::Initializer(\n const std::initializer_list\u003c Initializer \u003e & v\n)\n``` \nConstruct a multi-dimensional tensor from a nested initializer list.\n\nNote that C++ syntax allows nesting of arbitrarily typed initializer lists, so such invalid initializers cannot be disallowed at compile time. This function performs checks to make sure that the nested initializer list is indeed a valid multi-dimensional tensor."]]