《Efficient Deep Learning Book》[EDL] Chapter 5 - Advanced Compression Techniques
= simulate_clustering( x, num_clusters, num_steps=5000, learning_rate=2e-1) The following is the log of the above training. Computing the centroids. Step: 1000, Loss: 0.04999. Step: 2000, Loss: 0.03865 the number of clusters ( ). Figure 5-7 (b) shows the plot. Note that both the x and y axes are in log-scale. Finally, figure 5-7 (c) compares the reconstruction errors between quantization and clustering clustering. The centroids mimic the distribution of x. (b) Change in reconstruction loss as the number of clusters (both x and y axes are in log scale). (c) Comparison of reconstruction errors for both0 码力 | 34 页 | 3.18 MB | 1 年前3Lecture 7: K-Means
cluster means µk = mean(Ck) = 1 |Ck| � x∈Ck x Stop when cluster means or the “loss” does not change by much Feng Li (SDU) K-Means December 28, 2021 8 / 46 K-means: Initialization (assume K = 2) Can also information criterion such as AIC (Akaike Information Crite- rion) AIC = 2L(ˆµ, X, ˆZ) + K log D and choose the K that has the smallest AIC (discourages large K) Feng Li (SDU) K-Means December0 码力 | 46 页 | 9.78 MB | 1 年前3动手学深度学习 v2.0
包含a行和b列的实数矩阵集合 • A ∪ B: 集合A和B的并集 13 • A ∩ B:集合A和B的交集 • A \ B:集合A与集合B相减,B关于A的相对补集 函数和运算符 • f(·):函数 • log(·):自然对数 • exp(·): 指数函数 • 1X : 指示函数 • (·)⊤: 向量或矩阵的转置 • X−1: 矩阵的逆 • ⊙: 按元素相乘 • [·, ·]:连结 • |X|:集合的基数 �→'identity_transform', 'independent', 'kl', 'kl_divergence', 'kumaraswamy', 'laplace', 'lkj_cholesky', �→'log_normal', 'logistic_normal', 'lowrank_multivariate_normal', 'mixture_same_family', 'multinomial', 但是我们可以在不改变目标的前提下,通过最大化似然对数来简化。由于历史原因,优化通常是说最小化而 不是最大化。我们可以改为最小化负对数似然− log P(y | X)。由此可以得到的数学公式是: − log P(y | X) = n � i=1 1 2 log(2πσ2) + 1 2σ2 � y(i) − w⊤x(i) − b �2 . (3.1.15) 现在我们只需要假设σ是某个固定常数0 码力 | 797 页 | 29.45 MB | 1 年前3Lecture 5: Gaussian Discriminant Analysis, Naive Bayes
122 Warm Up (Contd.) Log-likelihood function ℓ(θ) = log m � i=1 pX,Y (x(i), y(i)) = log m � i=1 pX|Y (x(i) | y(i))pY (y(i)) = m � i=1 � log pX|Y (x(i) | y(i)) + log pY (y(i)) � where θ = {pX|Y Given m sample data, the log-likelihood is ℓ(ψ, µ0, µ1, Σ) = log m � i=1 pX,Y (x(i), y(i); ψ, µ0, µ1, Σ) = log m � i=1 pX|Y (x(i) | y(i); µ0, µ1, Σ)pY (y(i); ψ) = m � i=1 log pX|Y (x(i) | y(i); µ0 + m � i=1 log pY (y(i); ψ) Feng Li (SDU) GDA, NB and EM September 27, 2023 46 / 122 Gaussian Discriminant Analysis (Contd.) The log-likelihood function ℓ(ψ, µ0, µ1, Σ) = m � i=1 log pX|Y (x(i) |0 码力 | 122 页 | 1.35 MB | 1 年前3Lecture Notes on Gaussian Discriminant Analysis, Naive
y(i))}i=1,··· ,m, the log-likelihood is defined as ℓ(ψ, µ0, µ1, Σ) = log m � i=1 pX,Y (x(i), y(i); ψ, µ0, µ1, Σ) = log m � i=1 pX|Y (x(i) | y(i); µ0, µ1, Σ)pY (y(i); ψ) = m � i=1 log pX|Y (x(i) | y(i); + m � i=1 log pY (y(i); ψ)(8) where ψ, µ0, and σ are parameters. Substituting Eq. (5)∼(7) into Eq. (8) gives 2 us a full expression of ℓ(ψ, µ0, µ1, Σ) ℓ(ψ, µ0, µ1, Σ) = m � i=1 log pX|Y (x(i) | m � i=1 log pY (y(i); ψ) = � i:y(i)=0 log � 1 (2π)n/2|Σ|1/2 exp � −1 2(x − µ0)T Σ−1(x − µ0) �� + � i:y(i)=1 log � 1 (2π)n/2|Σ|1/2 exp � −1 2(x − µ1)T Σ−1(x − µ1) �� + m � i=1 log ψy(i)(1 −0 码力 | 19 页 | 238.80 KB | 1 年前3Lecture 4: Regularization and Bayesian Statistics
J(θ) = − 1 m m � i=1 [y(i) log(hθ(x(i))) + (1 − y(i)) log(1 − hθ(x(i)))] Adding a term for regularization J(θ) = − 1 m m � i=1 [y(i) log(hθ(x(i)))+(1−y(i)) log(1−hθ(x(i)))]+ λ 2m n � j=1 θ2 m � i=1 p(d(i); θ) MLE typically maximizes the log-likelihood instead of the likelihood ℓ(θ) = log L(θ) = log m � i=1 p(d(i); θ) = m � i=1 log p(d(i); θ) Maximum likelihood parameter estimation estimation θMLE = arg max θ ℓ(θ) = arg max θ m � i=1 log p(d(i); θ) Feng Li (SDU) Regularization and Bayesian Statistics September 20, 2023 13 / 25 Maximum-a-Posteriori Estimation (MAP) Maximum-a-Posteriori0 码力 | 25 页 | 185.30 KB | 1 年前3【PyTorch深度学习-龙龙老师】-测试版202112
对数运算,例如常见的loge 、log2 、log1 等,可以直接调用 torch.log()、 torch.log2()、torch.log10()等函数实现。自然对数loge 实现如下: In [98]: x = torch.arange(3).float() # 转换为浮点数 x = torch.exp(x) # 先指数运算 torch.log(x) # 再对数运算 Out[98]: Out[98]: tensor([0., 1., 2.]) 如果希望计算其它底数的对数,可以根据对数的换底公式: log? = loge loge ? 间接地通过 torch.log()实现。这里假设不调用 torch.log10()函数,通过换底公式算 loge ? loge 1 来间 接计,实现如下: In [99]: x = torch.tensor([1 PyTorch 基础 36 x = 10**x # 指数运算 torch.log(x)/torch.log(torch.tensor(10.)) # 换底公式计算 Log10 Out[99]: tensor([1., 2.]) 实现起来并不麻烦。实际中通常使用 torch.log()函数就够了。 4.9.4 矩阵相乘运算 神经网络中间包含了大量的矩阵相乘0 码力 | 439 页 | 29.91 MB | 1 年前3机器学习课程-温州大学-03机器学习-逻辑回归
合起来,我们得到逻辑回归模型的假设函数: 当? ? 大于等于0.5时,预测 y=1 当? ? 小于0.5时,预测 y=0 Sigmoid 函数 ?=?T? + ? ൯ L ̰? , ? = −?log(̰?) − (1 − ?)log(1 − ̰? 2.Sigmoid函数 注意:若表达式 ℎ ? = ? = ?0 + ?1?1 + ?2?2+. . . +???? + ? = ?T? + ?, 则?可以融入到 之比为 ? 1−?, 称为事件的发生比(the odds of experiencing an event) 其中?为随机事件发生的概率,?的范围为[0,1]。 取对数得到:log ? 1−?,而log ? 1−? = ?T? = ? 求解得到:? = 1 1+?−?T? = 1 1+?−? 10 2.Sigmoid函数 将?进行逻辑变换:? ? = 1 1+?− ̰? , ? = −?log(̰?) − (1 − ?)log(1 − ̰? 为了衡量算法在全部训练样本上的表现如何,我们需要定义一个算法的代价函 数,算法的代价函数是对?个样本的损失函数求和然后除以?: ? ? = 1 ? σ?=1 ? L ̰? (?) , ?(?) = 1 ? σ?=1 ? −?(?)log ̰? (?) − (1 − ?(?))log(1 − ̰? (?))0 码力 | 23 页 | 1.20 MB | 1 年前3机器学习课程-温州大学-02深度学习-神经网络的编程基础
y=1 当? ? 小于0.5时,预测 y=0 sigmoid 函数 ?=??? + ? ൯ ? ̰? , ? = −?log(̰?) − (1 − ?)log(1 − ̰? 6 逻辑回归 损失函数 ൯ ? ̰? , ? = −?log(̰?) − (1 − ?)log(1 − ̰? 为了衡量算法在全部训练样本上的表现如何,我们需要定义一个算法的代价函 数,算法的代价函数是对?个样本的损失函数求和然后除以 (?) , ?(?) = 1 ? σ?=1 ? −?(?)log ̰? (?) − (1 − ?(?))log(1 − ̰? (?)) 代价函数 ̰? 表示预测值 ? 表示真实值 7 逻辑回归的梯度下降 损失函数 ? ̰? , ? ൯ ? ̰? , ? = ? ?, ? = −?log(?) − (1 − ?)log(1 − ? ? = ̰? 设: 因为??(?,?) (1−?)) ⋅ ?(1 − ?) = ? − ? ?=??? + ? 8 逻辑回归的梯度下降 损失函数 ? ̰? , ? ൯ ? ̰? , ? = ? ?, ? = −?log(?) − (1 − ?)log(1 − ? ? = ̰? 设: 因为??(?,?) ?? = ?? ?? = (?? ??) ⋅ (?? ??), 并且?? ?? = ? ⋅ (1 − ?), 而0 码力 | 27 页 | 1.54 MB | 1 年前3Lecture 3: Logistic Regression
/ 29 Logistic Regression Formulation (Contd.) Maximize the log likelihood ℓ(θ) = log L(θ) = m � i=1 � y(i) log h(x(i)) + (1 − y(i)) log(1 − h(x(i)) � Gradient ascent algorithm θj ← θj + α ▽θj ℓ(θ) Regression September 20, 2023 27 / 29 Softmax Regression (Contd.) Log-likelihood function ℓ(θ) = m � i=1 log p(y(i)|x(i); θ) = m � i=1 log K � k=1 � � exp � θ(k)Tx(i)� �K k′=1 exp � θ(k′)Tx(i) �0 码力 | 29 页 | 660.51 KB | 1 年前3
共 42 条
- 1
- 2
- 3
- 4
- 5