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.
dòng chảy căng:: ôi:: StringSplitV2
#include <string_ops.h>
Tách các phần tử của source
dựa trên sep
thành SparseTensor
.
Bản tóm tắt
Gọi N là kích thước của nguồn (thông thường N sẽ là kích thước lô). Phân tách từng phần tử của source
dựa trên sep
và trả về SparseTensor
chứa mã thông báo được phân tách. Mã thông báo trống sẽ bị bỏ qua.
Ví dụ: N = 2, source[0] là 'hello world' và source[1] là 'ab c', thì đầu ra sẽ là
st.indices = [0, 0;
0, 1;
1, 0;
1, 1;
1, 2]
st.shape = [2, 3]
st.values = ['hello', 'world', 'a', 'b', 'c']
Nếu đưa ra sep
, các dấu phân cách liên tiếp sẽ không được nhóm lại với nhau và được coi là phân cách các chuỗi trống. Ví dụ: nguồn của "1\<\>2\<\>\<\>3"
và sep của "\<\>"
trả về ["1", "2", "", "3"]
. Nếu sep
là Không hoặc một chuỗi trống, khoảng trắng liên tiếp được coi là một dấu phân cách duy nhất và kết quả sẽ không chứa chuỗi trống ở cuối phần bắt đầu nếu chuỗi có khoảng trắng ở đầu hoặc cuối.
Lưu ý rằng hành vi được đề cập ở trên khớp với str.split của python.
Lập luận:
- phạm vi: Một đối tượng phạm vi
- đầu vào:
Tensor
chuỗi 1-D
, các chuỗi cần phân tách. - sep:
Tensor
chuỗi 0-D
, ký tự phân cách.
Thuộc tính tùy chọn (xem Attrs
):
- maxsplit: Một
int
. Nếu maxsplit > 0
, giới hạn phân chia kết quả.
Trả về:
Các hàm tĩnh công khai |
---|
Maxsplit (int64 x) | |
Thuộc tính công khai
Chức năng công cộng
Các hàm tĩnh công khai
Chia tối đa
Attrs Maxsplit(
int64 x
)
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-25 UTC.
[null,null,["Cập nhật lần gần đây nhất: 2025-07-25 UTC."],[],[],null,["# tensorflow::ops::StringSplitV2 Class Reference\n\ntensorflow::ops::StringSplitV2\n==============================\n\n`#include \u003cstring_ops.h\u003e`\n\nSplit elements of `source` based on `sep` into a `SparseTensor`.\n\nSummary\n-------\n\nLet N be the size of source (typically N will be the batch size). Split each element of `source` based on `sep` and return a `SparseTensor` containing the split tokens. [Empty](/versions/r1.15/api_docs/cc/class/tensorflow/ops/empty#classtensorflow_1_1ops_1_1_empty) tokens are ignored.\n\nFor example, N = 2, source\\[0\\] is 'hello world' and source\\[1\\] is 'a b c', then the output will be \n\n```text\nst.indices = [0, 0;\n 0, 1;\n 1, 0;\n 1, 1;\n 1, 2]\nst.shape = [2, 3]\nst.values = ['hello', 'world', 'a', 'b', 'c']\n```\n\n\u003cbr /\u003e\n\nIf `sep` is given, consecutive delimiters are not grouped together and are deemed to delimit empty strings. For example, source of `\"1\\\u003c\\\u003e2\\\u003c\\\u003e\\\u003c\\\u003e3\"` and sep of `\"\\\u003c\\\u003e\"` returns `[\"1\", \"2\", \"\", \"3\"]`. If `sep` is None or an empty string, consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the startor end if the string has leading or trailing whitespace.\n\nNote that the above mentioned behavior matches python's str.split.\n\nArguments:\n\n- scope: A [Scope](/versions/r1.15/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input: `1-D` string [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor), the strings to split.\n- sep: `0-D` string [Tensor](/versions/r1.15/api_docs/cc/class/tensorflow/tensor#classtensorflow_1_1_tensor), the delimiter character.\n\n\u003cbr /\u003e\n\nOptional attributes (see [Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/string-split-v2/attrs#structtensorflow_1_1ops_1_1_string_split_v2_1_1_attrs)):\n\n- maxsplit: An `int`. If `maxsplit \u003e 0`, limit of the split of the result.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) indices\n- [Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) values\n- [Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) shape\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [StringSplitV2](#classtensorflow_1_1ops_1_1_string_split_v2_1acbea51cb12f95ef6cae1972ae134e7ac)`(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)` sep)` ||\n| [StringSplitV2](#classtensorflow_1_1ops_1_1_string_split_v2_1a63b63775de3ac1b5830b860233d56cbc)`(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)` sep, const `[StringSplitV2::Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/string-split-v2/attrs#structtensorflow_1_1ops_1_1_string_split_v2_1_1_attrs)` & attrs)` ||\n\n| ### Public attributes ||\n|---------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------|\n| [indices](#classtensorflow_1_1ops_1_1_string_split_v2_1afd84236fdcaab70d550ed4c31069c70b) | `::`[tensorflow::Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [operation](#classtensorflow_1_1ops_1_1_string_split_v2_1a58af1d625de74aabfd6fbf24fc8f5000) | [Operation](/versions/r1.15/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [shape](#classtensorflow_1_1ops_1_1_string_split_v2_1af40d55ff0d2df1679c54c1d41e13dccf) | `::`[tensorflow::Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [values](#classtensorflow_1_1ops_1_1_string_split_v2_1a06c7c35d77269fee3efbc2f4a6987c30) | `::`[tensorflow::Output](/versions/r1.15/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n\n| ### Public static functions ||\n|-------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|\n| [Maxsplit](#classtensorflow_1_1ops_1_1_string_split_v2_1a33e93526de570b25c067a8a35545e5b2)`(int64 x)` | [Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/string-split-v2/attrs#structtensorflow_1_1ops_1_1_string_split_v2_1_1_attrs) |\n\n| ### Structs ||\n|------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [tensorflow::ops::StringSplitV2::Attrs](/versions/r1.15/api_docs/cc/struct/tensorflow/ops/string-split-v2/attrs) | Optional attribute setters for [StringSplitV2](/versions/r1.15/api_docs/cc/class/tensorflow/ops/string-split-v2#classtensorflow_1_1ops_1_1_string_split_v2). |\n\nPublic attributes\n-----------------\n\n### indices\n\n```text\n::tensorflow::Output indices\n``` \n\n### operation\n\n```text\nOperation operation\n``` \n\n### shape\n\n```text\n::tensorflow::Output shape\n``` \n\n### values\n\n```text\n::tensorflow::Output values\n``` \n\nPublic functions\n----------------\n\n### StringSplitV2\n\n```gdscript\n StringSplitV2(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input sep\n)\n``` \n\n### StringSplitV2\n\n```gdscript\n StringSplitV2(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input sep,\n const StringSplitV2::Attrs & attrs\n)\n``` \n\nPublic static functions\n-----------------------\n\n### Maxsplit\n\n```text\nAttrs Maxsplit(\n int64 x\n)\n```"]]