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:: Lượng tử hóaDownAndShrinkRange
#include <math_ops.h>
Chuyển đổi tenxơ 'đầu vào' được lượng tử hóa thành 'đầu ra' có độ chính xác thấp hơn bằng cách sử dụng.
Bản tóm tắt
phân phối thực tế của các giá trị để tối đa hóa việc sử dụng độ sâu bit thấp hơn và điều chỉnh phạm vi tối thiểu và tối đa đầu ra tương ứng.
[input_min, input_max] là các số float vô hướng chỉ định phạm vi để diễn giải float của dữ liệu 'đầu vào'. Ví dụ: nếu input_min là -1.0f và input_max là 1.0f và chúng ta đang xử lý dữ liệu lượng tử hóa quint16, thì giá trị 0 trong dữ liệu 16 bit sẽ được hiểu là -1.0f và 65535 có nghĩa là 1.0f.
Toán tử này cố gắng thu được độ chính xác cao nhất có thể vào đầu ra có độ sâu bit thấp hơn bằng cách tính toán các giá trị tối thiểu và tối đa thực tế được tìm thấy trong dữ liệu. Ví dụ: có thể đầu vào quint16 đó không có giá trị nào thấp hơn 16.384 và không có giá trị nào cao hơn 49.152. Điều đó có nghĩa là thực tế chỉ cần một nửa phạm vi, tất cả các cách diễn giải float nằm trong khoảng từ -0,5f đến 0,5f, vì vậy nếu chúng ta muốn nén dữ liệu thành đầu ra quint8, chúng ta có thể sử dụng phạm vi đó thay vì -1,0f đến 1,0 theo lý thuyết f được đề xuất bởi đầu vào tối thiểu và tối đa.
Trong thực tế, điều này hữu ích nhất để lấy đầu ra từ các hoạt động như QuantizedMatMul có thể tạo ra đầu ra có độ sâu bit cao hơn đầu vào của chúng và có thể có phạm vi đầu ra tiềm năng lớn, nhưng trên thực tế có sự phân bổ các giá trị đầu vào chỉ sử dụng một phần nhỏ của phạm vi có thể. Bằng cách đưa đầu ra đó vào toán tử này, chúng ta có thể giảm nó từ 32 bit xuống còn 8 với độ chính xác bị mất ở mức tối thiểu.
Lập luận:
- phạm vi: Một đối tượng Phạm vi
- input_min: Giá trị float mà giá trị đầu vào lượng tử hóa tối thiểu đại diện.
- input_max: Giá trị float mà giá trị đầu vào lượng tử hóa tối đa đại diện.
- out_type: Loại đầu ra. Nên có độ sâu bit thấp hơn Tinput.
Trả về:
-
Output
đầu ra -
Output
out_min: Giá trị float mà giá trị đầu ra lượng tử hóa tối thiểu đại diện. -
Output
out_max: Giá trị float mà giá trị đầu ra lượng tử hóa tối đa đại diện.
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::ops::QuantizeDownAndShrinkRange Class Reference\n\ntensorflow::ops::QuantizeDownAndShrinkRange\n===========================================\n\n`#include \u003cmath_ops.h\u003e`\n\nConvert the quantized 'input' tensor into a lower-precision 'output', using the.\n\nSummary\n-------\n\nactual distribution of the values to maximize the usage of the lower bit depth and adjusting the output min and max ranges accordingly.\n\n\\[input_min, input_max\\] are scalar floats that specify the range for the float interpretation of the 'input' data. For example, if input_min is -1.0f and input_max is 1.0f, and we are dealing with quint16 quantized data, then a 0 value in the 16-bit data should be interpreted as -1.0f, and a 65535 means 1.0f.\n\nThis operator tries to squeeze as much precision as possible into an output with a lower bit depth by calculating the actual min and max values found in the data. For example, maybe that quint16 input has no values lower than 16,384 and none higher than 49,152. That means only half the range is actually needed, all the float interpretations are between -0.5f and 0.5f, so if we want to compress the data into a quint8 output, we can use that range rather than the theoretical -1.0f to 1.0f that is suggested by the input min and max.\n\nIn practice, this is most useful for taking output from operations like [QuantizedMatMul](/versions/r2.1/api_docs/cc/class/tensorflow/ops/quantized-mat-mul#classtensorflow_1_1ops_1_1_quantized_mat_mul) that can produce higher bit-depth outputs than their inputs and may have large potential output ranges, but in practice have a distribution of input values that only uses a small fraction of the possible range. By feeding that output into this operator, we can reduce it from 32 bits down to 8 with minimal loss of accuracy.\n\nArguments:\n\n- scope: A [Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object\n- input_min: The float value that the minimum quantized input value represents.\n- input_max: The float value that the maximum quantized input value represents.\n- out_type: The type of the output. Should be a lower bit depth than Tinput.\n\n\u003cbr /\u003e\n\nReturns:\n\n- [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) output\n- [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) output_min: The float value that the minimum quantized output value represents.\n- [Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) output_max: The float value that the maximum quantized output value represents.\n\n\u003cbr /\u003e\n\n| ### Constructors and Destructors ||\n|---|---|\n| [QuantizeDownAndShrinkRange](#classtensorflow_1_1ops_1_1_quantize_down_and_shrink_range_1a19ee578c7b888e9aca48d291a1a0d5da)`(const ::`[tensorflow::Scope](/versions/r2.1/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope)` & scope, ::`[tensorflow::Input](/versions/r2.1/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input, ::`[tensorflow::Input](/versions/r2.1/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input_min, ::`[tensorflow::Input](/versions/r2.1/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input)` input_max, DataType out_type)` ||\n\n| ### Public attributes ||\n|-------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| [operation](#classtensorflow_1_1ops_1_1_quantize_down_and_shrink_range_1a3ab13cf6f6f7814f990022d1a49b3a99) | [Operation](/versions/r2.1/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation) |\n| [output](#classtensorflow_1_1ops_1_1_quantize_down_and_shrink_range_1a02ce18813489b86884040f42ddcfca87) | `::`[tensorflow::Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [output_max](#classtensorflow_1_1ops_1_1_quantize_down_and_shrink_range_1a3c2857dfc27b8777dc82845ec0a4919a) | `::`[tensorflow::Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\n| [output_min](#classtensorflow_1_1ops_1_1_quantize_down_and_shrink_range_1aa8dddbbd62576e4961029ce5ed846677) | `::`[tensorflow::Output](/versions/r2.1/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output) |\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\n### output_max\n\n```scdoc\n::tensorflow::Output output_max\n``` \n\n### output_min\n\n```scdoc\n::tensorflow::Output output_min\n``` \n\nPublic functions\n----------------\n\n### QuantizeDownAndShrinkRange\n\n```gdscript\n QuantizeDownAndShrinkRange(\n const ::tensorflow::Scope & scope,\n ::tensorflow::Input input,\n ::tensorflow::Input input_min,\n ::tensorflow::Input input_max,\n DataType out_type\n)\n```"]]