线性分类器:Batch Perception+Ho_Kashyap+MSE原理及代码实现

损失函数——均方误差(Mean Squared Error,MSE) 在使用MSE作为损失函数进行优化时,通常会采用梯度下降等优化算法来最小化MSE的值,从而提高模型的性能。MSE的值越小,说明模型的预测值与真实值之间的差异越小,模型的性能越好。如果需要在训练模型时使用MSE作为损失函数进行优化,可以在训练循环中计算损失,并使用反向传播算法更新模型参数。在PyTorch中,可以使用内置的MSE损失函数来计算均方误差。其中,n是样本数量,xi是第i个样本的真实值,yi是模型对第i个样本的预测值。在上面的代码中,首先创建了真实值和预测值的张量,然后使用PyTorch内置的。 阅读详情

使用数据

在这里插入图片描述

Batch Perception算法

原理

设有一组样本 y 1 , y 2 , . . . , y n y_1,y_2,...,y_n y1​,y2​,...,yn​,各样本均规范化表示,我们的目的是找一个解向量 a a a ,使 a T y i > 0 a^T y_i>0 aTyi​>0。在线性可分的情况下,满足上式的 a a a是无穷的。所以要引出一个损失函数进行优化。这个准则的基本思想是错分样本最少:
J ( a ) = ∑ y ∈ Y ( − a T y ) J(a)=\sum_{y\in Y}(-a^{T}y) J(a)=∑y∈Y​(−aTy)
Y Y Y为错分样本集合。我们采用梯度下降来优化目标函数:
∂ J ∂ a = ∑ y ∈ Y ( − y ) \frac{\partial J}{\partial a}=\sum_{y\in Y}(-y) ∂a∂J​=∑y∈Y​(−y)
则有:
a k + 1 = a k − η ∑ y ∈ Y ( − y ) a_{k+1}=a_{k}-η\sum_{y\in Y}(-y) ak+1​=ak​−η∑y∈Y​(−y)

代码实现

# Define batch perception algorithm
# Input: w1, w2
#   w1: Samples in class 1
#   w2: Samples in class 2
# Output: a, n
#   a: the parameters
#   n: number of iterations
def batch_perception(w1, w2):
    # Generate the normalized augmented samples
    w = trans_sample(w1, w2)
    
    # Initiation
    a = np.zeros_like(w[1])
    eta = 1                             # Learning rate
    theta = np.zeros_like(w[1])+1e-6    # Termination conditions
    n = 0                               # Number of iterations

    # Implement the algorithm
    while True:
        y = np.zeros_like(w[1])
        for sample in w:
            if np.matmul(a.T, sample) <= 0:
                # the sample is misclassified 
                y += sample
        eta_y = eta * y

        if all(np.abs(eta_y)<=theta):
            # if the termination conditions are satisfied, terminate the iteration
            break

        a += eta_y
        n += 1
    
    print ("The dicision surface a is {}\nThe number of iterations is {}.".format(a, n))
    return a, n

Ho-Kashyap算法

原理

刚才的准则函数都是关注于错分样本,而对正确分类的样本则没有考虑在内。MSE准则函数把求解目标从不等式形式变成了等式形式:求取满足 a T y i = b i a^T y_i=b_i aTyi​=bi​的权向量。在这里, b i b_i bi​是任取的正常数。

如果记矩阵 Y ∈ R n ∗ d Y\in R^{n*d} Y∈Rn∗d且其每行都是一个样本 y T y^T yT,向量 b = [ b 1 , b 2 , . . . , b n ] T b=[b_1,b_2,...,b_n]^T b=[b1​,b2​,...,bn​]T,那么就可以表述为存在 Y a = b > 0 Ya=b>0 Ya=b>0。为了求解这个问题,使用MSE准则函数:
J = ∣ ∣ Y a − b ∣ ∣ 2 = ∑ i = 1 n ( a T y i − b i ) 2 J=||Ya-b||^2=\sum_{i=1}^{n}(a^T y_i-b_i)^2 J=∣∣Ya−b∣∣2=∑i=1n​(aTyi​−bi​)2

采用梯度下降来优化目标函数:
∂ J ∂ a = 2 Y T ( Y a − b ) \frac{\partial J}{\partial a}=2Y^T(Ya-b) ∂a∂J​=2YT(Ya−b)
∂ J ∂ b = − 2 ( Y a − b ) \frac{\partial J}{\partial b}=-2(Ya-b) ∂b∂J​=−2(Ya−b)
则有:
b k + 1 = b k + 2 η k 1 2 ( ∂ J ∂ b − ∣ ∂ J ∂ b ∣ ) b_{k+1}=b_k+2η_{k}\frac{1}{2}(\frac{\partial J}{\partial b}-|\frac{\partial J}{\partial b}|) bk+1​=bk​+2ηk​21​(∂b∂J​−∣∂b∂J​∣)
a k = Y + b k a_{k}=Y^{+}b_k ak​=Y+bk​

代码实现

# Define Ho-Kashyap algorithm
# Input: w1, w2
#   w1: Samples in class 1
#   w2: Samples in class 2
# Output: a, b, n
#   a, b: the parameters
#   e: training errors
def HK_algorithm(w1, w2):
    # Generate the normalized augmented samples
    w = trans_sample(w1, w2)
    
    # Initiation
    a = np.zeros_like(w[1])
    b = np.zeros(w.shape[0]) + 0.5
    yita = 0.5                          # learning rate
    th_b = np.zeros(w.shape[0]) + 1e-6  # Termination condition of b
    th_n = 10000                        # Termination condition of n
    n = 0                               # Number of iterations

    # Implement the algorithm
    while n <= th_n:
        e = np.matmul(w, a) - b
        e_ = 0.5 * (e + np.abs(e))
        b += 2 * (yita) * e_
        a = np.matmul(np.matmul(np.linalg.inv(np.matmul(w.T, w)), w.T), b)
        n += 1

        if all(np.abs(e) == 0): 
            # if the errors are all 0, terminate the iteration
            print ("The dicision surface a is {}.".format(a))
            print ("The dicision errors are {}.".format(e))
            return a, b, e
        if all(np.abs(e) <= th_b): 
            # if the termination conditions are satisfied, terminate the iteration
            print ("The dicision surface a is {}.".format(a))
            print ("The dicision errors are {}.".format(e))
            return a, b, e
    
    # if the termination conditions are not satisfied when n = th_n, terminate the iteration
    print ("Iteration exceed the maxinum number! No solution found !")
    print ("The current dicision surface a is {}.".format(a))
    print ("The current dicision errors are {}.".format(e))
    return a, b, e

MSE算法

原理

采用c个两类分类器的组合,使用线性变换:
y = W T x + b , W ∈ E d ∗ c , b ∈ R c y=W^{T}x+b,W\in E^{d*c},b\in R^{c} y=WTx+b,W∈Ed∗c,b∈Rc
决策准则:
如果 j = a r g m a x ( W T x + b ) j=argmax(W^{T}x+b) j=argmax(WTx+b),则 x ∈ ω j x\in \omega_j x∈ωj​
在这里插入图片描述
令 W ^ = W b T , x ^ = x 1 ∈ R d + 1 , X ^ = ( x 1 ^ , x 2 ^ , . . . , x n ^ ) ∈ R ( d + 1 ) ∗ n \hat{W}=\begin{matrix}W\\b^T\\\end{matrix},\hat{x}=\begin{matrix}x\\1\\\end{matrix}\in R^{d+1}, \hat{X}=(\hat{x_1},\hat{x_2},...,\hat{x_n})\in R^{(d+1)*n} W^=WbT​,x^=x1​∈Rd+1,X^=(x1​^​,x2​^​,...,xn​^​)∈R(d+1)∗n
目标函数:
m i n W , b ∑ i = 1 n ∣ ∣ W T x + b − y i ∣ 2 2 min_{W,b}\sum_{i=1}^{n}||W^{T}x+b-y_i|^2_2 minW,b​∑i=1n​∣∣WTx+b−yi​∣22​
∑ i = 1 n ∣ ∣ W T x + b − y i ∣ 2 2 = ∣ ∣ W ^ T X ^ − Y ∣ ∣ F 2 \sum_{i=1}^{n}||W^{T}x+b-y_i|^2_2=||\hat{W}^{T}\hat{X}-Y||_F^2 ∑i=1n​∣∣WTx+b−yi​∣22​=∣∣W^TX^−Y∣∣F2​
得到:
W ^ = ( X ^ X ^ T + λ I ) − 1 X ^ Y T ∈ R ( d + 1 ) ∗ c \hat{W}=(\hat{X}\hat{X}^{T}+\lambda I)^{-1}\hat{X}Y^{T}\in R^{(d+1)*c} W^=(X^X^T+λI)−1X^YT∈R(d+1)∗c

代码实现

# Define the multiple classed test function
# Input: w, a
#   w: [[class1], [class2], ...]
#   a: the parameters (sample_d+1, class_n)
# Output: f_ratio
#   f_ratio: false ratio
def multi_class_mse_test(w, a):
    w_ = copy.deepcopy(w)
    cnt = 0

    for class_i, sample in enumerate(w_):
        print(sample)
        for sample_i, test_sample in enumerate(sample):
            test_sample.append(1)
            test_sample = np.array(test_sample)
            print(np.matmul(a.T, test_sample))
            test_result = np.argmax(np.matmul(a.T, test_sample))
            if test_result != class_i: 
                cnt += 1

    f_ratio = cnt / ((class_i+1)*(sample_i+1))

    print("The false rate is {} ".format(f_ratio))

    return f_ratio

代码汇总

import numpy as np
import matplotlib.pyplot as plt
import copy


# Sample w1, w2, w3, w4
w1 = [[0.1, 1.1],   [6.8, 7.1],   [-3.5, -4.1], [2.0, 2.7],   [4.1, 2.8],   [3.1, 5.0],   [-0.8, -1.3], [0.9, 1.2],   [5.0, 6.4],   [3.9, 4.0]]
w2 = [[7.1, 4.2],   [-1.4, -4.3], [4.5, 0.0],   [6.3, 1.6],   [4.2, 1.9],   [1.4, -3.2],  [2.4, -4.0],  [2.5, -6.1],  [8.4, 3.7],   [4.1, -2.2]]
w3 = [[-3.0, -2.9], [0.5, 8.7],   [2.9, 2.1],   [-0.1, 5.2],  [-4.0, 2.2],  [-1.3, 3.7],  [-3.4, 6.2],  [-4.1, 3.4],  [-5.1, 1.6],  [1.9, 5.1]]
w4 = [[-2.0, -8.4], [-8.9, 0.2],  [-4.2, -7.7], [-8.5, -3.2], [-6.7, -4.0], [-0.5, -9.2], [-5.3, -6.7], [-8.7, -6.4], [-7.1, -9.7], [-8.0, -6.3]]


# Generate the normalized augmented samples
# Input: w1, w2 
#   w1: samples in class 1
#   w2: samples in class 2
# Output: w
#   w: normalized augmented samples in class 1 and a
def trans_sample(w1,w2):
    w_1 = copy.deepcopy(w1)
    w_2 = copy.deepcopy(w2)

    # Augmentation
    for sample in w_1: 
        sample.append(1)
    for sample in w_2: 
        sample.append(1)

    # Regulation
    w_1 = np.array(w_1)
    w_2 = -np.array(w_2)
    w   = np.concatenate([w_1, w_2])

    return w


# Define batch perception algorithm
# Input: w1, w2
#   w1: Samples in class 1
#   w2: Samples in class 2
# Output: a, n
#   a: the parameters
#   n: number of iterations
def batch_perception(w1, w2):
    # Generate the normalized augmented samples
    w = trans_sample(w1, w2)
    
    # Initiation
    a = np.zeros_like(w[1])
    eta = 1                             # Learning rate
    theta = np.zeros_like(w[1])+1e-6    # Termination conditions
    n = 0                               # Number of iterations

    # Implement the algorithm
    while True:
        y = np.zeros_like(w[1])
        for sample in w:
            if np.matmul(a.T, sample) <= 0:
                # the sample is misclassified 
                y += sample
        eta_y = eta * y

        if all(np.abs(eta_y)<=theta):
            # if the termination conditions are satisfied, terminate the iteration
            break

        a += eta_y
        n += 1
    
    print ("The dicision surface a is {}\nThe number of iterations is {}.".format(a, n))
    return a, n


# Define Ho-Kashyap algorithm
# Input: w1, w2
#   w1: Samples in class 1
#   w2: Samples in class 2
# Output: a, b, n
#   a, b: the parameters
#   e: training errors
def HK_algorithm(w1, w2):
    # Generate the normalized augmented samples
    w = trans_sample(w1, w2)
    
    # Initiation
    a = np.zeros_like(w[1])
    b = np.zeros(w.shape[0]) + 0.5
    yita = 0.5                          # learning rate
    th_b = np.zeros(w.shape[0]) + 1e-6  # Termination condition of b
    th_n = 10000                        # Termination condition of n
    n = 0                               # Number of iterations

    # Implement the algorithm
    while n <= th_n:
        e = np.matmul(w, a) - b
        e_ = 0.5 * (e + np.abs(e))
        b += 2 * (yita) * e_
        a = np.matmul(np.matmul(np.linalg.inv(np.matmul(w.T, w)), w.T), b)
        n += 1

        if all(np.abs(e) == 0): 
            # if the errors are all 0, terminate the iteration
            print ("The dicision surface a is {}.".format(a))
            print ("The dicision errors are {}.".format(e))
            return a, b, e
        if all(np.abs(e) <= th_b): 
            # if the termination conditions are satisfied, terminate the iteration
            print ("The dicision surface a is {}.".format(a))
            print ("The dicision errors are {}.".format(e))
            return a, b, e
    
    # if the termination conditions are not satisfied when n = th_n, terminate the iteration
    print ("Iteration exceed the maxinum number! No solution found !")
    print ("The current dicision surface a is {}.".format(a))
    print ("The current dicision errors are {}.".format(e))
    return a, b, e


# Define multiple class MSE algorithm
# Input: w
#   w: [[class1], [class2], ...]
# Output: a 
#   a: the parameters (sample_d+1, class_n)
def multi_class_mse(w_i):
    w_ = copy.deepcopy(w_i)
    class_n = len(w_)
    sample_n = len(w_[0])

    # Initiation
    w = []
    y = np.zeros((class_n, class_n*sample_n))
    for class_idx, class_sample in enumerate(w_):
        for sample in class_sample: 
            sample.append(1)
            w.append(sample)
        y[class_idx, class_idx*sample_n:(class_idx+1)*sample_n] = 1
    print(y)
    w = np.array(w).T 

    # w: (class_n*sample_n, 3)
    # y: (class_n, class_n*sample_n)
    a = np.matmul(np.matmul(np.linalg.inv(np.matmul(w, w.T)+0.01), w), y.T)
    
    print ("The dicision surface a is {}.".format(a))
    return a


# Define the multiple classed test function
# Input: w, a
#   w: [[class1], [class2], ...]
#   a: the parameters (sample_d+1, class_n)
# Output: f_ratio
#   f_ratio: false ratio
def multi_class_mse_test(w, a):
    w_ = copy.deepcopy(w)
    cnt = 0

    for class_i, sample in enumerate(w_):
        print(sample)
        for sample_i, test_sample in enumerate(sample):
            test_sample.append(1)
            test_sample = np.array(test_sample)
            print(np.matmul(a.T, test_sample))
            test_result = np.argmax(np.matmul(a.T, test_sample))
            if test_result != class_i: 
                cnt += 1

    f_ratio = cnt / ((class_i+1)*(sample_i+1))

    print("The false rate is {} ".format(f_ratio))

    return f_ratio


# Show the classification results
# Input: w1, w2
#   w1: Samples in class 1
#   w2: Samples in class 2
#   a: the parameters 
def show_result(w1, w2, a):
    # Samples in class 1
    w_1 = np.array(w1)
    x1 = w_1[:, 0]
    y1 = w_1[:, 1]
    plt.scatter(x1, y1, marker = '.',color = 'red')

    # Samples in class 2
    w_2 = np.array(w2)
    x2 = w_2[:, 0]
    y2 = w_2[:, 1]
    plt.scatter(x2, y2, marker = '.',color = 'blue')

    # Decision surface
    x = np.arange(-10, 10, 0.1)
    y = -a[0]/a[1]*x - a[2]/a[1]
    plt.plot(x, y)
    
    plt.xlabel('x_1')
    plt.ylabel('x_2')
    plt.title('Classfication Result')
    plt.show()


# Show the multiple classification results
# Input: w, a
#   w: [[class1], [class2], ...]
#   a: the parameters
def multi_class_show_result(w, a):
    class_n = len(w)

    for class_idx, class_sample in enumerate(w):
        # Samples in class_idx
        w_i = np.array(class_sample)
        x = w_i[:, 0]
        y = w_i[:, 1]
        plt.scatter(x, y)

        # Decision surface
        x = np.arange(-10, 10, 0.1)
        y = -a[0][class_idx]/a[1][class_idx]*x - a[2][class_idx]/a[1][class_idx]
        plt.plot(x, y)
    
    plt.xlabel('x_1')
    plt.ylabel('x_2')
    plt.title('Classfication Result')
    plt.show()


if __name__ == "__main__":
    print("The result of the batch perception algorithm is shown below")
    print("w1 and w2")
    a, n = batch_perception(w1, w2)
    show_result(w1, w2, a)
    print("w3 and w2")
    a, n = batch_perception(w3, w2)
    show_result(w3, w2, a)

    print("-------------------------------------")
    print("The result of the Ho-Kashyap algorithm is shown below")
    print("w1 and w3")
    a, b, e = HK_algorithm(w1, w3)
    show_result(w1, w3, a)
    print("w2 and w4")
    a, b, e = HK_algorithm(w2, w4)
    show_result(w2, w4, a)

    print("-------------------------------------")
    print("The result of the multiple calss MSE is shown below")
    a = multi_class_mse([w1[:8], w2[:8], w3[:8], w4[:8]])
    multi_class_show_result([w1[:8], w2[:8], w3[:8], w4[:8]], a)
    multi_class_mse_test([w1[8:], w2[8:], w3[8:], w4[8:]], a)
Code | 线性分类器:批量感知算法+Ho_Kashyap算法(二分类)+MSE多类扩展 1. 数据 2. import matplotlib.pyplot as plt import numpy as np x = np.loadtxt('data.txt') b = np.ones(40) y = np.insert(x, 0, b, 1) # 增广 class BatchPerception(): def __init__(self, w1, w2, y): self.w1 = w1 self.w2 = w2 self 阅读详情

相关推荐

机器学习算法-感知机

机器学习算法-感知机 感知机是线性分类模型,属于判别模型,感知机旨在求出将训练数据进行线性划分的分离超平面。感知机模型: f(x)=sign(w⋅x+b)f(x)=sign(w \cdot x+b )f(x)=sign(w⋅x+b) x∈Rnx \in \mathcal{R}^nx∈Rn,w⋅x+b=0w \cdot x+b=0w⋅x+b=0是nnn维空间的超平面 1. 预处理-样本规范化 样本规范化有两部分: 齐次增广表示:将样本和模型权重采用齐次增广表示: y=(1x)={1,x1,x2,...,xd

weixin_42595206的博客 763

Ho-Kashyap Algorithm 原理笔记

Ho-Kashyap 算法 任务:给定样本{x1,x2,...,xn},xi=[xi1,xi2,⋯ ,xid]T\{x_1,x_2,...,x_n\},x_i=[x_{i1},x_{i_2},\cdots,x_{id}]^T{x1​,x2​,...,xn​},xi​=[xi1​,xi2​​,⋯,xid​]T,设每个样本属于两类中的某一类{1,−1}\{1,-1\}{1,−1},用线性模型对样本进行划分。 方法: 将每个xix_ixi​转化成yiy_iyi​,如果xix_ixi​属于{1}类,yi=[1,xi

weixin_44839047的博客 1216

超详细 | 哈里斯鹰优化算法原理、实现及其改进与利用(Matlab/Python)

测试函数为F9在MATLAB中执行程序结果如下:在Python中执行程序结果如下:哈里斯鹰优化算法(Harris Hawks Optimization , HHO)是 Heidari等[1]于2019年提出的一种新型元启发式算法,设计灵感来源于哈里斯鹰在捕食猎物过程中的合作行为以及突然袭击的狩猎风格,算法的寻优过程包括探索、探索与开发转换和开发三个阶段。具有需调参数少、原理简单易实现、局部搜索能力强等优点。在数值和工程优化、图像识别、故障诊断、电网优化设计、等工程领域得到广泛的应用。

sfejojno的博客 1万+

深度学习代码|MSE损失的代码实现

一般在反向传播时,都是先求loss,再使用loss.backward()求loss对每个参数 w_ij和b的偏导数(也可以理解为梯度)。但是只有标量才能执行backward()函数,因此在反向传播中reduction不能设为"none"。NumPy 是 Python 语言的一个第三方库,支持大量高维度数组与矩阵运算。此外,NumPy 也针对数组运算提供大量的数学函数。机器学习涉及到大量对数组的变换和运算,NumPy 就成了必不可少的工具之一。具体地,在深度学习中,可以使用该函数用来计算两个特征图的相似性。

weixin_47748259的博客 3160

Ho-Kashyap算法.doc

为了保证算法可以收敛到分类超平面,必须做出改进。我们知道,对于线性可分的数据一定可以找到解向量 aa 使 a⊤yi>0a⊤yi>0 对所有样本 yiyi( i=1,2,⋯,Ni=1,2,⋯,N)都成立。那么换句话说,一定存在一个 aa 和 bb ,使下式成立 Ya=b>0 Ya=b>0 接下来要做的就是调整MSE的准则函数,做法就是让 bb 也是需要学习的参数,而不是事先指定好的,这就引出了Ho-Kashyap算法

Ho-Kashyap算法

Ho-Kashyap算法,用于求解判别界面方程。

LMSE-HK算法

H-K算法即通过最小均方误差求解最优权向量的过程,相较感知器算法固定增量的迭代,H-K算法可以在模式线性不可分的情况下停止迭代。那么代价呢就是需要计算高维逆矩阵,????进行分析。 对于给定的N个n维模式,如果数据线性可分,则必存在w(n+1维)使得下列成立: 将属于ω2的模式乘以(-1),可得对于全部模式都有的条件。 设两类模式的训练样本总数为N,写成增广形式,则有不等式组: Xw>...

qq_36302589的博客 5809

计算MSE的matlab代码

计算MSE的代码,MSE常用于评估图像去噪结果等等。

机器学习 —— 基础整理(六)线性判别函数:感知器、松弛算法、Ho-Kashyap算法...

这篇总结继续复习分类问题。本文简单整理了以下内容: (一)线性判别函数与广义线性判别函数 (二)感知器 (三)松弛算法 (四)Ho-Kashyap算法 闲话:本篇是本系列[机器学习基础整理]在timeline上最新的,但实际上还有(七)、(八)都发布的比这个早,因为这个系列的博客是之前早就写好的,不过会抽空在后台修改,感觉自己看不出错误(当然因为水平有限肯定还是会...

weixin_34232363的博客 809

BatchPerception_模式识别_批处理感知器_

实现简单的数据分类,并动态显示分类结果。

学习样本优化 Ho-Kashyap 分类算法附matlab代码.zip

1.版本:matlab2014/2019a,内含运行结果,不会运行可私信 2.领域:智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,更多内容可点击博主头像 3.内容:标题所示,对于介绍可点击主页搜索博客 4.适合人群:本科,硕士等教研学习使用 5.博客介绍:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可si信

chatgpt赋能python:Python求mse——介绍和步骤详解

均方误差(MSE)是机器学习中的常见性能指标之一,用于衡量预测值和实际值之间的误差大小。MSE越小,表示模型的预测越准确。其中,y_pred是模型的预测值,y_true是实际值,n是样本数量。本文由chatgpt生成,文章没有在chatgpt生成的基础上进行任何的修改。以上只是chatgpt能力的冰山一角。作为通用的Aigc大模型,只是展现它原本的实力。对于颠覆工作方式的ChatGPT,应该选择拥抱而不是抗拒,未来属于“会用”AI的人。🧡AI职场汇报智能办公文案写作效率提升教程 🧡专注于。

turensu的博客 2343

grpc安装与简单demo测试

grpc安装: 由于工作需要,最近在学google的rpc开源框架;由于本人菜鸟一枚,而且是从Windows开发转到Linux;由于之前版本控制使用的是svn,没有使用过git,所以从GitHub上下载代码是通过浏览器下载zip格式的压缩文件,折腾了好几天了,发现了各种坑,各种缺少库,各种不知道怎么把这个库给装机器上。对于一个不熟悉Linux的人来说,这个体验简直糟糕透了。没办法了又在机器上装了...

old__captain的博客 4833

计算机视觉(三)线性分类器

目录 线性分类器 数据集介绍 分类器设计 图像类型 图像表示 选择分类模型 线性分类器 权值w 分界面/决策边界 损失函数 多类支持向量机损失 正则项 超参数 L2正则项 L1正则项 优化算法(梯度下降) 梯度下降算法 随机梯度下降算法 小批量梯度下降算法 数据集划分 训练数据 测试数据 验证数据 K折交叉验证 数据预处理 线性分类器 数据集介绍 CIFAR10,5w张训练样本,1w张测试样本,含飞机、汽车、鸟、猫、船、卡车等十个类别图像均为彩色图像

weixin_37699342的博客 3031

【02】【VisionMaster V4.0.0 】安装教程—— 授权文件更新报错:应用程序与本地LM通讯出错(怀疑电脑加密 和 上网受限 造成的 )

本文详细介绍了海康VisionMaster 4.0试用版的安装流程及常见问题解决方案。主要内容包括:1)从官网下载基础安装包、试用补丁和授权文件;2)按顺序安装主程序、补丁和授权文件;3)针对授权失败问题提供两种解决方案(更换未加密电脑或使用加密狗);4)说明试用版的功能限制(30天试用期、2个流程限制等)。文章特别指出电脑加密可能导致授权失败,并提供了安装报错时的处理建议,为初次使用者提供了完整的安装指导。

程序员,他们想的是什么?他们想的永远都是技术,他们崇尚的也永远都是技术。 7166

Win10下ISE14.7安装避坑全记录:从License加载失败到ChipScope连不上,我踩过的雷都在这了

本文详细记录了在Win10系统下安装ISE14.7时遇到的常见问题及解决方案,包括License加载失败、IMPACT闪退、ChipScope连接故障等。通过实际案例和步骤解析,帮助用户避开安装陷阱,确保FPGA开发工具顺利运行。特别针对license问题提供了兼容性设置和文件修改的实用技巧。

weixin_42683394的博客 225

回归指标评价定义及代码(MSE,RMSE,MAE,MAPE,R2-score)

利用python语言对回归指标进行简要讲解。 目录 MSE RMSE MAE MAPE R2-score 代码 MSE 定义:MSE(均方误差)函数一般用来检测模型的预测值和真实值之间的偏差。MSE是真实值与预测值的差值的平方然后求和平均。通过平方的形式便于求导,所以常被用作线性回归的损失函数。 RMSE 定义:RMSE(均方根误差)在MSE的基础上做平方根衡量观测值与真实值之间的偏差。常用来作为机器学习模型预测结果衡量的标准。 MAE 定义:MAE(Mea

holal的博客 1万+

AvFrame和AvPacket

在FFmpeg中,未压缩的图像和压缩的视频码流分别使用AVFrame结构和AVPacket结构保存;针对视频编码器,其流程为从数据源获取图像格式的输入数据,保存为AVFrame对象并传入编码器,从编码器输出AVPacket结构。

Lce的专栏 3236

sklearn【MSE】均方误差,原理及学习代码!

均方误差(Mean Squared Error,MSE)是回归问题中常用的一个评估指标,它通过计算预测值与实际值之间差异的平方的平均值来评估模型的精度。在Python的机器学习库sklearn中,我们可以使用内置的mean_squared_error函数来计算MSE。收集数据:首先,我们需要一组包含实际目标值(真实值)和模型预测值的数据集。这些数据通常来自测试集,用于评估模型在未见过的数据上的性能。计算残差。

高级数据分析师,分享Python知识 5208

深入解析CAN2.0A与CAN2.0B协议:帧格式与通信机制对比

本文深入对比了CAN2.0A与CAN2.0B协议的核心差异,重点解析了11位标准帧与29位扩展帧的帧格式、标识符长度及通信机制。文章阐述了CAN2.0B向下兼容的特性,并探讨了在汽车电子、工业控制等复杂网络中,如何根据项目需求、兼容性及实时性要求,在标准帧与扩展帧之间做出合理选择。

weixin_29163797的博客 394

QT 实现QStackedWidget切换页面右移动画

首先截取当前界面的图片,渲染到一个QLabel上,然后设置QPropertyAnimation动画,动画的作用对象就是这个QLabel,不断的改变geometry;当动画结束的时候,隐藏并释放这个QLabel。以下是一个QStackedWidget,放了两个QPushButton在上面,点击切换不同的界面。为了方便查看动画特效,设置了每个界面的背景图片。

希望能帮助大家,希望大家多多支持,你们的支持是我前进的动力。 882

【机器学习】均方误差(MSE:Mean Squared Error)

均方误差(Mean Squared Error, MSE)是衡量预测值与真实值之间差异的一种方法。在统计学和机器学习中,MSE 是一种常见的损失函数,用于评估模型的预测准确性。

IT古董 8165

【Qt图书管理系统】5.完整版源码及下载地址

Qt图书管理系统完整源码下载。

小鱼酱的博客 7001

线性判别函数:感知器、松弛算法、Ho-Kashyap算法

http://www.cnblogs.com/Determined22/p/6507329.html

finlay 2676

从win系统远程使用服务器中的nsight system、nsight compute

本文介绍了如何在Windows系统中远程使用服务器上的Nsight System和Nsight Compute工具。主要内容包括:1)双系统同步安装相同版本的Nsight工具,配置环境变量;2)命令行生成profile文件或直接运行分析;3)Windows远程连接服务器的配置方法;4)解决权限问题的具体方案,如修改文件夹权限或调整NVIDIA驱动配置。文章提供了详细的安装步骤和常见问题解决方案,适用于需要进行GPU性能分析和调试的开发人员。

Justinyh的博客 401

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

AI全栈实战 | 3.9-01 爬虫入门:requests 加 BeautifulSoup 三分钟跑通,但 90% 的人栽在这 4 个“礼貌“问题上

⚠️:本文内容仅用于。请遵守目标站点的服务条款与相关法律法规,不得对目标服务造成负担,不得采集、传播个人隐私数据。技术是中性的,边界在你手里。爬虫的入门技术(requests 发请求 + BeautifulSoup 解析)三分钟就能学会。真正区分"会用爬虫"和"会做爬虫的人"的,是这篇我们跑通"请求→解析→存储"的最小闭环,然后重点把"合规与礼貌"这根弦给你绷上。

源码获取 | 运行部署 | 定制二开修改,如果回复不及时请耐心等待,请见谅。 405

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

上一篇: 多智能体强化学习思路整理
下一篇: 【已解决】Paragon NTFS for mac彻底删除
Ceder1c
博客等级 码龄7年 268粉丝 44原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值