寫一個直方圖摘要。
用法
tf.summary.histogram(
name, data, step=None, buckets=None, description=None
)
參數
-
name
此摘要的名稱。用於 TensorBoard 的摘要標記將是此名稱,以任何活動名稱範圍為前綴。 -
data
任何形狀的Tensor
。直方圖是根據其元素計算的,這些元素必須可轉換為float64
。 -
step
此摘要的顯式int64
-castable 單調步長 值。如果省略,則默認為tf.summary.experimental.get_step()
,不能為 None。 -
buckets
可選的正麵int
。輸出將有這麽多桶,除了兩個邊情況。如果沒有數據,則沒有桶。如果有數據但所有點的值都相同,則所有桶的左右端點相同,隻有最後一個桶的計數非零。 -
description
此摘要的可選長格式說明,作為常量str
。支持Markdown 。默認為空。
返回
- 成功時為真,如果因為沒有可用的默認摘要編寫器而未發出摘要,則為假。
拋出
-
ValueError
如果存在默認編寫器,但未提供任何步驟且tf.summary.experimental.get_step()
為無。
另見tf.summary.scalar
、tf.summary.SummaryWriter
。
將直方圖寫入當前默認摘要編寫器,以便稍後在 TensorBoard 的 'Histograms' 和 'Distributions' 儀表板中進行分析(使用此 API 寫入的數據將出現在這兩個位置)。與 tf.summary.scalar
點一樣,每個直方圖都與 step
和 name
相關聯。所有具有相同name
的直方圖構成一個時間序列的直方圖。
直方圖是在給定 Tensor
的所有元素上計算的,而不考慮其形狀或等級。
此示例寫入 2 個直方圖:
w = tf.summary.create_file_writer('test/logs')
with w.as_default():
tf.summary.histogram("activations", tf.random.uniform([100, 50]), step=0)
tf.summary.histogram("initial_weights", tf.random.normal([1000]), step=0)
一個常見的用例是檢查神經網絡中特定層隨時間變化的激活模式(或缺乏激活模式)。
w = tf.summary.create_file_writer('test/logs')
with w.as_default():
for step in range(100):
# Generate fake "activations".
activations = [
tf.random.normal([1000], mean=step, stddev=1),
tf.random.normal([1000], mean=step, stddev=10),
tf.random.normal([1000], mean=step, stddev=100),
]
tf.summary.histogram("layer1/activate", activations[0], step=step)
tf.summary.histogram("layer2/activate", activations[1], step=step)
tf.summary.histogram("layer3/activate", activations[2], step=step)
相關用法
- Python tf.summary.scalar用法及代碼示例
- Python tf.summary.text用法及代碼示例
- Python tf.summary.record_if用法及代碼示例
- Python tf.summary.experimental.summary_scope用法及代碼示例
- Python tf.summary.SummaryWriter.as_default用法及代碼示例
- Python tf.summary.graph用法及代碼示例
- Python tf.summary.image用法及代碼示例
- Python tf.strings.substr用法及代碼示例
- Python tf.strings.reduce_join用法及代碼示例
- Python tf.sparse.cross用法及代碼示例
- Python tf.sparse.mask用法及代碼示例
- Python tf.strings.regex_full_match用法及代碼示例
- Python tf.sparse.split用法及代碼示例
- Python tf.strings.regex_replace用法及代碼示例
- Python tf.signal.overlap_and_add用法及代碼示例
- Python tf.strings.length用法及代碼示例
- Python tf.strided_slice用法及代碼示例
- Python tf.sparse.to_dense用法及代碼示例
- Python tf.strings.bytes_split用法及代碼示例
- Python tf.shape用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.summary.histogram。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。