打印張量列表。 (已棄用)
用法
tf.compat.v1.Print(
input_, data, message=None, first_n=None, summarize=None, name=None
)
參數
-
input_
一個張量通過了這個操作。 -
data
計算 op 時要打印的張量列表。 -
message
一個字符串,錯誤消息的前綴。 -
first_n
僅記錄first_n
次數。始終記錄負數;這是默認設置。 -
summarize
隻打印每個張量的這麽多條目。如果沒有,則每個輸入張量最多打印 3 個元素。 -
name
操作的名稱(可選)。
返回
-
A
Tensor
.具有相同的類型和內容input_
.sess = tf.compat.v1.Session() with sess.as_default(): tensor = tf.range(10) print_op = tf.print(tensor) with tf.control_dependencies([print_op]): out = tf.add(tensor, tensor) sess.run(out)
遷移到 TF2
警告:這個 API 是為 TensorFlow v1 設計的。繼續閱讀有關如何從該 API 遷移到本機 TensorFlow v2 等效項的詳細信息。見TensorFlow v1 到 TensorFlow v2 遷移指南有關如何遷移其餘代碼的說明。
此 API 已棄用。請改用tf.print
。 tf.print
不需要 input_
參數。
tf.print
在 TF2 中即刻執行時和在 tf.function
內工作。
在 TF1 風格的會話中,需要顯式的控製依賴聲明來執行 tf.print
操作。有關詳細信息,請參閱tf.print
的文檔。
警告:此函數已棄用。它將在 2018-08-20 之後刪除。更新說明:使用 tf.print 代替 tf.Print。請注意,tf.print 返回一個直接打印輸出的no-output 運算符。在 defuns 或 Eager 模式之外,除非在 session.run 中直接指定或用作其他運算符的控製依賴項,否則不會執行此運算符。這隻是圖形模式下的一個問題。以下是如何確保 tf.print 在圖形模式下執行的示例:
這是一個身份操作(行為類似於 tf.identity
),具有在評估時打印 data
的副作用。
注意:此操作打印到標準錯誤。目前與 jupyter notebook 不兼容(打印到 notebook服務器的輸出,而不是進入筆記本)。
相關用法
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python tf.compat.v1.data.TFRecordDataset.interleave用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.cross_entropy用法及代碼示例
- Python tf.compat.v1.Variable.eval用法及代碼示例
- Python tf.compat.v1.train.FtrlOptimizer.compute_gradients用法及代碼示例
- Python tf.compat.v1.layers.conv3d用法及代碼示例
- Python tf.compat.v1.strings.length用法及代碼示例
- Python tf.compat.v1.data.Dataset.snapshot用法及代碼示例
- Python tf.compat.v1.data.experimental.SqlDataset.reduce用法及代碼示例
- Python tf.compat.v1.feature_column.categorical_column_with_vocabulary_file用法及代碼示例
- Python tf.compat.v1.data.TextLineDataset.from_tensors用法及代碼示例
- Python tf.compat.v1.variable_scope用法及代碼示例
- Python tf.compat.v1.data.experimental.SqlDataset.as_numpy_iterator用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.covariance用法及代碼示例
- Python tf.compat.v1.placeholder用法及代碼示例
- Python tf.compat.v1.layers.Conv3D用法及代碼示例
- Python tf.compat.v1.train.get_or_create_global_step用法及代碼示例
- Python tf.compat.v1.nn.static_rnn用法及代碼示例
- Python tf.compat.v1.debugging.assert_shapes用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.Print。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。