Skip to Main Content
机器学习设计模式
book

机器学习设计模式

by Valliappa Lakshmanan, Sara Robinson, Michael Munn
September 2022
Beginner to intermediate content levelBeginner to intermediate
386 pages
7h 36m
Chinese
Southeast University Press
Content preview from 机器学习设计模式
42
2
底线是我们需要使用指纹哈希算法,并且我们需要对得到的哈希值进行模运算。
操作顺序
请注意,我们先求模,然后求绝对值:
CREATE TEMPORARY FUNCTION hashed(airport STRING, numbuckets INT64) AS (
ABS(MOD(FARM_FINGERPRINT(airport), numbuckets))
);
前面的代码片段中
ABS
MOD
FARM_FINGERPRINT
的顺序很重要,因为
INT64
取值范围是不对称的。具体来说,它的范围在
-9,223,372,036,854,775,808
9,223,372,036,854,775,807
之间(两者都包括在内)。所以,如果我们要这样做:
ABS(FARM_FINGERPRINT(airport))
如果
FARM_FINGERPRINT
操作碰巧返回
-9,223,372,036,854,775,808
,我们将遇到一
个罕见且可能无法复现的溢出错误因为它的绝对值不能用
INT64
表示!
空哈希桶
尽管不太可能,但即使我们选择
10
个哈希桶来代表
347
个机场,其中一个哈希桶也
有可能是空的。因此,当使用哈希特征列时,也使用
L2
正则化可能是有益的(
https://
oreil.ly/xlwAH
),这样与空桶相关的权值将被驱动到接近于
0
。这样,即使一个词汇
表外的机场真的掉进了一个空桶里,也不会导致模型在数值上变得不稳定。
设计模式
2
:嵌入
嵌入(
Embeddings
)是一种可学习的数据表示,它将高基数数据映射到低维空间, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PyTorch深度学习

PyTorch深度学习

Posts & Telecom Press, Vishnu Subramanian
数据科学原理

数据科学原理

Posts & Telecom Press, Sinan Ozdemir
Rust程序设计

Rust程序设计

Jim Blandy, Jason Orendorff, Leonora F. S. Tindall

Publisher Resources

ISBN: 9787564196776