TensorFlow Lite学习笔记

TensorFlow Lite学习笔记(参考Module: tf.lite  |  TensorFlow Lite (google.cn)

 

总共分为六块:

Interpreter: 推理

model_content:

num_threads:tflite的卷积推理支持多线程,这里可以指定线程数

tf.lite.Interpreter(
    model_path=None, model_content=None, experimental_delegates=None,
    num_threads=None
)

 

OpsSet: 参数类型

  • EXPERIMENTAL_TFLITE_BUILTINS_ACTIVATIONS_INT16_WEIGHTS_INT8
  • SELECT_TF_OPS
  • TFLITE_BUILTINS
  • TFLITE_BUILTINS_INT8

TFLITE_BUILTINS,SELECT_TF_OPS, EXPERIMENTAL_TFLITE_BUILTINS_ACTIVATIONS_INT16_WEIGHTS_INT8 都是在实验阶段,不建议使用

TFLITE_BUILTINS_INT8要用的化需要自定义数据集

 

Optimize: 生成TFlite图的时候优化方法

  • DEFAULT:
  • OPTIMIZE_FOR_LATENCY:优化算力
  • OPTIMIZE_FOR_SIZE:优化模型大小

 

RepresentativeDataset: 重定义数据集

 

TFLiteConverter: tflite转换器

支持

# Converting a SavedModel to a TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)
tflite_model = converter.convert()

#keras model xxx.h5
# Converting a tf.Keras model to a TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_keras_model(model)
tflite_model = converter.convert()

# Converting ConcreteFunctions to a TensorFlow Lite model.
converter = tf.lite.TFLiteConverter.from_concrete_functions([func])
tflite_model = converter.convert()

TargetSpec: 对于特定设备的特殊要求指定

supported_ops:比如二进制,正在实验阶段

supported_types:设备上支持的类型

tf.lite.TargetSpec(
    supported_ops=None, supported_types=None
)

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值