通過多個桶將輸入張量中的每個字符串轉換為其哈希模型。
用法
tf.strings.to_hash_bucket_strong(
input, num_buckets, key, name=None
)參數
-
inputTensor類型為string。分配哈希桶的字符串。 -
num_bucketsint即>= 1。桶的數量。 -
keyints的列表。用於種子哈希函數的鍵,作為兩個 uint64 元素的列表傳遞。 -
name操作的名稱(可選)。
返回
-
Tensor類型為int64。
哈希函數對進程中字符串的內容是確定性的。散列函數是鍵控散列函數,其中屬性key定義散列函數的鍵。 key 是一個包含 2 個元素的數組。
當輸入可能是惡意的時,強哈希很重要,例如帶有附加組件的 URL。攻擊者可能會嘗試將他們的輸入散列到同一個桶中以進行denial-of-service 攻擊或扭曲結果。強散列可用於使在桶上具有偏斜散列值分布的輸入變得困難。這要求散列函數由對手未知的high-entropy(隨機)"key" 播種。
額外的魯棒性的代價是計算時間比 tf.string_to_hash_bucket_fast 高出大約 4 倍。
例子:
tf.strings.to_hash_bucket_strong(["Hello", "TF"], 3, [1, 2]).numpy()
array([2, 0])
相關用法
- Python tf.strings.to_hash_bucket_fast用法及代碼示例
- Python tf.strings.to_hash_bucket用法及代碼示例
- Python tf.strings.to_number用法及代碼示例
- Python tf.strings.substr用法及代碼示例
- Python tf.strings.reduce_join用法及代碼示例
- Python tf.strings.regex_full_match用法及代碼示例
- Python tf.strings.regex_replace用法及代碼示例
- Python tf.strings.length用法及代碼示例
- Python tf.strings.bytes_split用法及代碼示例
- Python tf.strings.as_string用法及代碼示例
- Python tf.strings.unsorted_segment_join用法及代碼示例
- Python tf.strings.lower用法及代碼示例
- Python tf.strings.split用法及代碼示例
- Python tf.strings.upper用法及代碼示例
- Python tf.strings.unicode_decode_with_offsets用法及代碼示例
- Python tf.strings.join用法及代碼示例
- Python tf.strings.ngrams用法及代碼示例
- Python tf.strings.unicode_decode用法及代碼示例
- Python tf.strings.unicode_encode用法及代碼示例
- Python tf.strings.format用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.strings.to_hash_bucket_strong。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
