Optimum 文件

匯出函式

您正在檢視的是需要從原始碼安裝。如果你想透過常規的 pip 安裝,請檢視最新的穩定版本 (v1.27.0)。
Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

匯出函式

主要函式

optimum.exporters.tflite.export

< >

( model: TFPreTrainedModel config: TFLiteConfig output: Path task: typing.Optional[str] = None preprocessor: typing.Union[transformers.tokenization_utils_base.PreTrainedTokenizerBase, transformers.image_processing_utils.BaseImageProcessor, NoneType] = None quantization_config: typing.Optional[ForwardRef('TFLiteQuantizationConfig')] = None ) Tuple[List[str], List[str]]

引數

  • model (TFPreTrainedModel) — 要匯出的模型。
  • config (TFLiteConfig) — 與匯出模型關聯的 TFLite 配置。
  • output (Path) — 儲存匯出的 TFLite 模型的目錄。
  • task (Optional[str], 預設為 None) — 模型的任務。如果未指定,將自動推斷任務。僅靜態量化需要。
  • preprocessor (Optional[Preprocessor], 預設為 None) — 與模型關聯的預處理器。用於在校準期間將資料饋送給模型之前對資料集進行預處理。
  • quantization_config (Optional[TFLiteQuantizationConfig], 預設為 None) — 包含執行量化所需所有資訊的資料類。

返回

Tuple[List[str], List[str]]

一個元組,包含模型輸入有序列表,以及 TFLite 配置中的命名輸入。

將 TensorFlow 模型匯出為 TensorFlow Lite 模型。

實用函式

optimum.exporters.tflite.validate_model_outputs

< >

( config: TFLiteConfig reference_model: TFPreTrainedModel tflite_model_path: Path tflite_named_outputs: typing.List[str] atol: typing.Optional[float] = None )

引數

  • config (TFLiteConfig — 用於匯出模型的配置。
  • reference_model (~TFPreTrainedModel) — 用於匯出的模型。
  • tflite_model_path (Path) — 匯出模型的路徑。
  • tflite_named_outputs (List[str]) — 要檢查的輸出名稱。
  • atol (Optional[float], 預設為 None) — 參考模型和匯出模型之間輸出差異的絕對容差。

引發

ValueError

  • ValueError — 如果參考模型和匯出模型之間的輸出形狀或值不匹配。

透過檢查參考模型和匯出模型的輸出是否匹配來驗證匯出。

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.