天天看點

TensorFlow 2.10上線:Windows上擴充GPU支援,TF-DF 1.0釋出

作者:機器之心Pro

機器之心報道

機器之心編輯部

TensorFlow 2.10 已釋出,還沒有更新的小夥伴現在可以更新了。

近日,TensorFlow 官方宣布, TensorFlow 2.10 來了!距離上次 2.9 版本的更新僅僅過去三個月。

TensorFlow 2.10上線:Windows上擴充GPU支援,TF-DF 1.0釋出

TensorFlow 位址:https://blog.tensorflow.org/2022/09/whats-new-in-tensorflow-210.html

新版本的亮點包括:Keras 中新的使用者友好特性、Windows 中擴充 GPU 支援等等。此版本還标志着 TensorFlow 決策森林 (TF-DF) 1.0 版本的到來!

對于這一更新,網友還是很期待的,有人表示:「TensorFlow 2.10 增加了 64 位 Arm 支援,現在可以在 Arm 硬體上使用 pip install TensorFlow 進行安裝了。」

TensorFlow 2.10上線:Windows上擴充GPU支援,TF-DF 1.0釋出

還有人對 TF-DF 1.0 版本的到來感到非常驚喜,并表示這是自己最期待的。

TensorFlow 2.10上線:Windows上擴充GPU支援,TF-DF 1.0釋出

下面我們介紹一下新版本都有哪些改進。

TensorFlow 2.10 新特性

Keras

從 TensorFlow 2.10 開始,對 Keras 注意力層的 mask 處理(例如 tf.keras.layers.Attention、tf.keras.layers.AdditiveAttention ) 進行了擴充和統一。

現在 Transformer 自注意力塊可以寫成這樣:

import tensorflow as tf
embedding = tf.keras.layers.Embedding(
 input_dim=10,
 output_dim=3,
 mask_zero=True) # Infer a correct padding mask.
# Instantiate a Keras multi-head attention (MHA) layer,
# a layer normalization layer, and an `Add` layer object.
mha = tf.keras.layers.MultiHeadAttention(key_dim=4, num_heads=1)
layernorm = tf.keras.layers.LayerNormalization()
add = tf.keras.layers.Add()
# Test input.
x = tf.constant([[1, 2, 3, 4, 5, 0, 0, 0, 0],
 [1, 2, 1, 0, 0, 0, 0, 0, 0]])
# The embedding layer sets the mask.
x = embedding(x)
# The MHA layer uses and propagates the mask.
a = mha(query=x, key=x, value=x, use_causal_mask=True)
x = add([x, a]) # The `Add` layer propagates the mask.
x = layernorm(x)
# The mask made it through all layers.
print(x._keras_mask)           

輸出如下:

> tf.Tensor(
> [[ True True True True True False False False False]
> [ True True True False False False False False False]], shape=(2, > 9), dtype=bool)           

其次,在 Tensorflow2.9 版本中,tf.keras.callbacks.BackupAndRestore 回調将在 epoch 邊界備份模型和訓練狀态。在 Tensorflow 2.10 中,回調還可以每 N 個訓練 step 備份一次模型。

關于Keras 中新的使用者友好特性,還有一點值得說的是,從音頻檔案目錄中輕松生成音頻分類資料集,現在使用tf.keras.utils.audio_dataset_from_directory 功能,就能從 .wav 檔案目錄輕松生成音頻分類資料集。

改進 AArch64 CPU 性能:ACL / oneDNN 內建

TensorFlow 團隊與 Arm、AWS 和 Linaro 合作,通過 oneDNN 将 Arm 架構 (ACL) 的計算庫與 TensorFlow 內建,來加速 AArch64 CPU 的性能。從 TensorFlow 2.10 開始,你可以通過在運作 TensorFlow 程式之前設定環境變量 TF_ENABLE_ONEDNN_OPTS=1 來實作這一點。

在 Windows 上擴充 GPU 支援

TensorFlow 現在可以通過 TensorFlow-DirectML 插件在 Windows 上使用更廣泛的 GPU。使用者要在 AMD、Intel、NVIDIA 和 Qualcomm 等供應商提供的 DirectX 12-capable GPU 上進行模型訓練,請在本機 Windows 或 WSL2 上安裝與标準 TensorFlow CPU 包一起的插件。

TensorFlow 決策森林 1.0

随着 Tensorflow 2.10 的釋出,TF-DF(Tensorflow Decision Forests)1.0 版本正式來了。這是一個偉大的裡程碑,TensorFlow 團隊改進了文檔并建立了更全面的測試,以確定 TF-DF 為專業環境做好準備。

了解更多更新,請檢視 TensorFlow 官網。

繼續閱讀