日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程语言 > python >内容正文

python

合页损失,铰链损失_多点铰链损失功能 使用Python的线性代数

發(fā)布時(shí)間:2023/12/1 python 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 合页损失,铰链损失_多点铰链损失功能 使用Python的线性代数 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

合頁損失,鉸鏈損失

Hinge Loss is a loss function used in Machine Learning for training classifiers. The hinge loss is a maximum margin classification loss function and a major part of the SVM algorithm.

鉸鏈損失是機(jī)器學(xué)習(xí)中用于訓(xùn)練分類器的損失函數(shù)。 鉸鏈損失是最大余量分類損失函數(shù),是SVM算法的主要部分。

Hinge loss function is given by:

鉸鏈損耗函數(shù)由下式給出:

LossH = max(0,(1-Y*y))

損耗H = max(0,(1-Y * y))

Where, Y is the Label and

其中, Y是標(biāo)簽,

y = 𝜭.x

y = 𝜭.x

This is the general Hinge Loss function and in this tutorial, we are going to define a function for calculating the Hinge Loss for a multiple point (having one feature) with given 𝜭.

這是常規(guī)的Hinge Loss函數(shù),在本教程中,我們將定義一個(gè)函數(shù),用于計(jì)算給定𝜭的多點(diǎn)(具有一個(gè)特征)的Hinge Loss。

用于多點(diǎn)鉸鏈損失的Python代碼 (Python code for hinge loss for multiple points)

# Linear Algebra Learning Sequence # Hinge loss for Multiple Point import numpy as npdef hinge_loss_single(feature_vector, label, theta, theta_0):ydash = label*(np.matmul(theta,feature_vector) + theta_0)hinge = np.max([0.0, 1 - ydash*label])return hingedef hinge_loss_full(feature_matrix, labels, theta, theta_0):tothinge = 0num = len(feature_matrix)for i in range(num):tothinge = tothinge + hinge_loss_single(feature_matrix[i], labels[i], theta, theta_0)hinge = tothingereturn hingefeature_matrix = np.array([[2,2], [3,3], [7,0], [14,47]]) theta = np.array([0.002,0.6]) theta_0 = 0 labels = np.array([[1], [-1], [1], [-1]])hingell = hinge_loss_full(feature_matrix, labels, theta, theta_0)print('Data point: ', feature_matrix) print('\n\nCorresponding Labels: ', labels) print('\n\n Hingle Loss for given data :', hingell)

Output:

輸出:

Data point: [[ 2 2][ 3 3][ 7 0][14 47]]Corresponding Labels: [[ 1][-1][ 1][-1]]Hingle Loss for given data : [0.986]

翻譯自: https://www.includehelp.com/python/function-for-hinge-loss-for-multiple-points.aspx

合頁損失,鉸鏈損失

總結(jié)

以上是生活随笔為你收集整理的合页损失,铰链损失_多点铰链损失功能 使用Python的线性代数的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。