選自github機器之心編譯參與:吳攀
2015 年 11 月份,谷歌宣布開源了深度學習框架 TensorFlow,一年之後,TensorFlow 就已經成長為了 GitHub 上最受歡迎的深度學習框架(參見機器之心文章《深度 | TensorFlow 開源一周年:這可能是一份最完整的盤點》),儘管那時候 TensorFlow 的版本號還是 v0.11。現在,TensorFlow 的一歲生日之後兩個月,TensorFlow 社區終於決定將 TensorFlow 的版本號升至 1.x,並也已於昨日發布了 TensorFlow 1.0.0-alpha,其新增了實驗性的 Java API,並且提升了對 Android 的支持。
發布地址
官網:https://www.tensorflow.org/versions/r1.0/GitHub:https://github.com/tensorflow/tensorflow/releases
主要特性和提升
TensorFlow Debugger (tfdbg):命令行接口和 API增加新的 python 3 docker 鏡像使 pip 包兼容 pypi。現在可以通過 pip install tensorflow 命令來安裝 TensorFlow 了Android:人員檢測+跟蹤演示,是通過使用了深度神經網絡的可擴展目標檢測實現的Android:預構建的 libs 現在每晚(nightly)構建新的(實驗性的)Jave API:https://github.com/tensorflow/tensorflow/tree/master/tensorflow/java
API 的重要更改
TensorFlow/models 被移到了一個單獨的 GitHub repository.除法和取模運算符(/, //, %)現已匹配 Python(flooring)語義。這也適用於 tf.div 和 tf.mod。為了獲取強制的基於整數截斷的行為,你可以使用 tf.truncatediv 和 tf.truncatemod.tf.divide 現在是推薦的除法函數。tf.div 還將保留,但其語義將不會響應 Python 3 或 from future 機制.tf.reverse 現在是將軸的索引反轉。例如,tf.reverse(a, [True, False, True]) 現在必須寫成 tf.reverse(a, [0, 2])。tf.reverse_v2() 暫時保留,直到 1.0 final 版.tf.mul、tf.sub 和 tf.neg 被棄用,現在使用的是 tf.multiply、tf.subtract 和 tf.negative.tf.pack 和 tf.unpack 被啟用,現在使用的是 tf.stack 和 tf.unstack.TensorArray.pack 和 TensorArray.unpack 將被啟用,取而代之的是 TensorArray.stack 和 TensorArray.unstack.以下 Python 函數有參數修改,以在引用特定維度時使用 axis. 我們目前基於兼容性的考量而保留了原來的關鍵詞參數,但我們將在 1.0 final 版中移除它們。
tf.argmax: dimension 變成 axistf.argmin: dimension 變成 axistf.count_nonzero: reduction_indices 變成 axistf.expand_dims: dim 變成 axistf.reduce_all: reduction_indices 變成 axistf.reduce_any: reduction_indices 變成 axistf.reduce_join: reduction_indices 變成 axistf.reduce_logsumexp: reduction_indices 變成 axistf.reduce_max: reduction_indices 變成 axistf.reduce_mean: reduction_indices 變成 axistf.reduce_min: reduction_indices 變成 axistf.reduce_prod: reduction_indices 變成 axistf.reduce_sum: reduction_indices 變成 axistf.reverse_sequence: batch_dim 變成 batch_axis, seq_dim 變成 seq_axistf.sparse_concat: concat_dim 變成 axistf.sparse_reduce_sum: reduction_axes 變成 axistf.sparse_reduce_sum_sparse: reduction_axes 變成 axistf.sparse_split: split_dim 變成 axis
tf.listdiff 已被重命名為 tf.setdiff1d 以匹配 NumPy 命名.tf.inv 已被重命名為 tf.reciprocal(分量互逆)以避免和矩陣求逆的 np.inv 混淆tf.round 現在使用了四捨六入五留雙規則語義,以匹配 NumPy.tf.split 現在以相反的順序取參數,並使用了不同的關鍵詞。特別地,我們現在將 NumPy 順序匹配成了 tf.split(value, num_or_size_splits, axis).tf.sparse_split 現在以相反的順序取參數,並使用了不同的關鍵詞。特別地,我們現在將 NumPy 順序匹配成了 tf.sparse_split(sp_input, num_split, axis). 注意:現在我們暫時讓 tf.sparse_split 需要關鍵詞參數.啟用 tf.concat 運算符,現在請暫時切換成 tf.concat_v2 . 在 Beta 版中,我們將更新 tf.concat 以匹配 tf.concat_v2 的參數順序.tf.image.decode_jpeg 默認使用更快的 DCT 方法. 速度的提升犧牲了一點保真度。你可以通過特定屬性 dct_method='INTEGER_ACCURATE'來恢復原來的行為.tf.complex_abs 已被從 Python 接口移除. 應該使用 tf.abs,它支持複數張量.模板.var_scope 屬性重命名為 .variable_scopeSyncReplicasOptimizer 被移除,SyncReplicasOptimizerV2 重命名為 SyncReplicasOptimizer.tf.zeros_initializer() 和 tf.ones_initializer() 現在返回一個 callable,其必須用 initializer 參數調用,在你的代碼中用 tf.zeros_initializer() 替代 tf.zeros_initializer.SparseTensor.shape 重命名為 SparseTensor.dense_shape. SparseTensorValue.shape 也一樣.移除了原來的 tf summary 運算符,比如 tf.scalar_summary 和 tf.histogram_summary. 取而代之的是 tf.summary.scalar 和 tf.summary.histogram .移除 tf.train.SummaryWriter 和 tf.train.SummaryWriterCache.從公共 API 中移除 RegisterShape . 現在使用 C++ 形狀函數註冊.從 Python API 棄用 _ref dtypes .
漏洞修復和其它更改
新指令: parallel_stack.為 RecordReader/RecordWriter 引入常見的 tf io 壓縮選項常量.添加 sparse_column_with_vocabulary_file,其能指定一個將字符串特徵轉換為 ID 的特徵列(feature column),其中的映射是通過一個詞彙表文件定義的.添加 index_to_string_table,其返回一個將索引映射到字符串的查找表.添加 string_to_index_table,其返回一個將字符串匹配到索引的查找表.添加一個 ParallelForWithWorkerId 函數.支持從 contrib/session_bundle 中的 v2 中的檢查點恢復會話.添加了一個用於任意角度的 tf.contrib.image.rotate 函數.添加了 tf.contrib.framework.filter_variables,這是一個用於基於正則表達式過濾變量列表的方便函數.make_template() 加入了一個可選的 custom_getter_ param.添加了關於現有目錄如何被 recursive_create_dir 處理的注釋.添加了用於 QR 因式分解的指令.Python API 中的除法和取模現在使用 flooring (Python) 語義.Android:在 contrib/android/cmake 下,用於 TensorFlow Inference 庫的 cmake/gradle buildAndroid:遠遠更加穩健的會話初始化代碼.Android:當 debug 模式激活時,TF stats 直接出現在演示和日誌中.Android:新的更好的 README.md 文檔.
致謝我們的貢獻者
這個版本包含了來自谷歌很多人的貢獻,此外還有以下貢獻者:
我們也非常感激所有提交了問題或幫助解決它們的所有人——提出和回答問題也是激發討論的一部分。
下載原始碼
zip :https://github.com/tensorflow/tensorflow/archive/v1.0.0-alpha.ziptar.gz:https://github.com/tensorflow/tensorflow/archive/v1.0.0-alpha.tar.gz