TensorFlow 2.7正式版上线,支持Jax模型到TensorFlow Lite转换

机器之心报道
机器之心编辑部

TensorFlow2.7 正式发布 , 新版本包括对 tf.keras、tf.lite 等模块的改进;tf.data 现在可以支持自动分片(auto-sharding);添加实验性 API Experiment_from_jax 以支持从 Jax 模型到 TensorFlow Lite 的转换 。
「调试代码(debug)是框架用户体验的关键部分 , 更轻松的调试意味着更快的迭代周期 。 在此版本中 , 我们通过三个主要更改对 TF/Keras 调试体验进行了广泛的重新设计 , 使其更高效、更有趣……」谷歌科学家 , Keras 发明者 Fran?ois Chollet 说道 。
11 月 5 日 , TensorFlow 官方发布了 2.7 正式版 , 距离上次 2.6.1 的更新刚过去一个月时间 。
TensorFlow 2.7正式版上线,支持Jax模型到TensorFlow Lite转换
文章图片

在 TensorFlow 博客上 , 官方简述了新版本的主要升级内容:
【TensorFlow 2.7正式版上线,支持Jax模型到TensorFlow Lite转换】TensorFlow 2.7 主要变化
tf.keras:
  • Model.fit()、 Model.predict() 和 Model.evaluate()方法将不再把 (batch_size, ) 的输入数据上升为 (batch_size, 1) 。 这使得 Model 子类能够在其 train_step()/ test_step()/ predict_step()方法中处理标量数据;
  • Model.to_yaml()和 keras.models.model_from_yaml 方法已被替换为引发 RuntimeError , 因为它们可能被滥用以导致任意代码执行 。 建议使用 JSON 序列化而不是 YAML , 或者 , 一个更好的替代方案 , 序列化到 H5;
  • LinearModel 和 WideDeepModel 被移至 tf.compat.v1.keras.models. 命名空间( tf.compat.v1.keras.models.LinearModel 和 tf.compat.v1.keras.models.WideDeepModel) , 其 experimental 端点 tf.keras.experimental.models.LinearModel 和 tf.keras.experimental.models.WideDeepModel 被弃用;
  • 所有 tf.keras.initializers 类的 RNG 行为改变 , 这一变化将使初始化行为在 v1 和 v2 之间保持一致 。
tf.lite:
  • 重命名 schema 中的 SignatureDef 表 , 以最大化与 TF SavedModel Signature 概念的奇偶校验 。
  • 弃用 Makefile 构建 , Makefile 用户需要将他们的构建迁移到 CMake 或 Bazel 。
  • 弃用 tflite::OpResolver::GetDelegates 。 TfLite 的 BuiltinOpResolver::GetDelegates 所返回的列表现在总是空的 。 相反 , 建议使用新方法 tflite::OpResolver::GetDelegateCreators 。
TF Core:
  • tf.Graph.get_name_scope() 现在总是返回一个字符串 。 之前当在 name_scope("") 或 name_scope(None) 上下文中调用时 , 它返回 None ,现在它返回空字符串;
  • tensorflow/core/ir/ 包含一个新的基于 MLIR 的 Graph dialect , 它与 GraphDef 同构 , 并将用于替换基于 GraphDef(例如 Grappler)的优化;
  • 弃用并删除了形状推理中的 attrs() 函数 , 现在所有的属性都应该通过名字来查询 。
  • 以下 Python 符号是在 TensorFlow 的早期版本中意外添加的 , 现在已被删除 。 每个符号都有一个替换项 , 但请注意替换项的参数名称是不同的:
  • tf.quantize_and_dequantize_v4(在 TensorFlow 2.4 中意外引入):改用 tf.quantization.quantize_and_dequantize_v2;
  • tf.batch_mat_mul_v3(在 TensorFlow 2.6 中意外引入):改用 tf.linalg.matmul;
  • tf.sparse_segment_sum_grad(在 TensorFlow 2.6 中意外引入):改用 tf.raw_ops.SparseSegmentSumGrad 。
将 tensorflow::int64 重命名为 int_64_t(前者是后者的别名) 。
模块化文件系统的迁移:

特别声明:本站内容均来自网友提供或互联网,仅供参考,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。