多类支持向量机损失(SVM损失)
创始人
2025-01-07 20:34:53
0

(SVM) 损失。SVM 损失的设置是,SVM“希望”每个图像的正确类别的得分比错误类别高出一定幅度Δ。
在这里插入图片描述
即假设有一个分数集合s=[13,−7,11]
如果y0为真实值,超参数为10,则该损失值为
在这里插入图片描述
超参数是指在机器学习算法的训练过程中需要设置的参数,它们不同于模型本身的参数(例如权重和偏置),是需要在训练之前预先确定的。超参数在模型训练和性能优化中起着关键作用。

正则化
在这里插入图片描述
在这里插入图片描述

def L_i(x, y, W):   """   unvectorized version. Compute the multiclass svm loss for a single example (x,y)   - x is a column vector representing an image (e.g. 3073 x 1 in CIFAR-10)     with an appended bias dimension in the 3073-rd position (i.e. bias trick)   - y is an integer giving index of correct class (e.g. between 0 and 9 in CIFAR-10)   - W is the weight matrix (e.g. 10 x 3073 in CIFAR-10)   """   delta = 1.0 # see notes about delta later in this section   scores = W.dot(x) # scores becomes of size 10 x 1, the scores for each class   correct_class_score = scores[y]   D = W.shape[0] # number of classes, e.g. 10   loss_i = 0.0   for j in range(D): # iterate over all wrong classes     if j == y:       # skip for the true class to only loop over incorrect classes       continue     # accumulate loss for the i-th example     loss_i += max(0, scores[j] - correct_class_score + delta)   return loss_i  def L_i_vectorized(x, y, W):   """   A faster half-vectorized implementation. half-vectorized   refers to the fact that for a single example the implementation contains   no for loops, but there is still one loop over the examples (outside this function)   """   delta = 1.0   scores = W.dot(x)   # compute the margins for all classes in one vector operation   margins = np.maximum(0, scores - scores[y] + delta)   # on y-th position scores[y] - scores[y] canceled and gave delta. We want   # to ignore the y-th position and only consider margin on max wrong class   margins[y] = 0   loss_i = np.sum(margins)   return loss_i  def L(X, y, W):   """   fully-vectorized implementation :   - X holds all the training examples as columns (e.g. 3073 x 50,000 in CIFAR-10)   - y is array of integers specifying correct class (e.g. 50,000-D array)   - W are weights (e.g. 10 x 3073)   """   # evaluate loss over all examples in X without using any for loops   # left as exercise to reader in the assignment 

相关内容

热门资讯

科技通报"同乡游辅助... 科技通报"同乡游辅助工具制作"同乡游辅助工具制作(其实是有挂)1、不需要AI权限,帮助你快速的进行同...
三分钟辅助器!海贝大厅辅助下载... 三分钟辅助器!海贝大厅辅助下载(辅助挂)分享教程(原本存在有挂);是一款可以让一直输的玩家,快速成为...
科技分享!新九天作弊系统(辅助... 科技分享!新九天作弊系统(辅助挂)原生真的有挂(详细辅助黑科技教程);1分钟了解详细教程(微信 13...
第八分钟了解!手机潮汕暗宝透视... 第八分钟了解!手机潮汕暗宝透视软件(辅助挂)果然是真的有挂(详细辅助软件);玩家必备必赢加哟《136...
第二分钟脚本!兴动互娱辅助工具... 第二分钟脚本!兴动互娱辅助工具免费(辅助挂)教你教程(一直有挂)1、构建自己的微扑克辅助插件;2、选...
最新通报"微乐山西脚... 最新通报"微乐山西脚本插件"微乐山西脚本插件(好像存在有挂);该软件可以轻松地帮助玩家将微乐山西脚本...
一起来讨论!新九五辅助(辅助挂... 1、一起来讨论!新九五辅助(辅助挂)果然是真的有挂(详细辅助新2025版);详细教程。2、新九五辅助...
第7分钟了解!九江讨赏插件(辅... 1、第7分钟了解!九江讨赏插件(辅助挂)竟然是真的有挂(详细辅助插件);详细教程。2、九江讨赏插件透...
第八分钟插件!蜀渝牌血战到底辅... 第八分钟插件!蜀渝牌血战到底辅助(辅助挂)黑科技教程(固有真的是有挂)蜀渝牌血战到底辅助辅助器中分为...
如何分辨真伪"福建宁... 如何分辨真伪"福建宁德麻将辅助软件"福建宁德麻将辅助软件(一贯有挂)1、下载好福建宁德麻将辅助软件辅...