如何使HOG特征向量适应线性svm输入 [英] How to adapt HOG features vector to linear svm input

查看:178
本文介绍了如何使HOG特征向量适应线性svm输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用HOG来通过图像A提取一组特征。
HOG返回1xN元素的特征向量。
但线性SVM仅接受每个样本的2个特征,即训练数据矩阵的大小为Mx2。所以我如何调整HOG矢量来训练线性SVM。
请帮帮我。
谢谢

I'm using HOG in order to extract a set of features trough an Image A. the HOG returns a features' vector of 1xN elements. However the linear SVM accept only 2 features for each sample i.e the training data matrix's size is Mx2. so how i can adapt the HOG vector to be trained on linear SVM. Please help me. Thanks

推荐答案

线性SVM仅接受每个样本的2个特征是什么意思?您可能会对SVM功能如何接受其训练数据感到困惑。以下是我如何使用它的快速示例:

What do you mean by "the linear SVM accept only 2 features for each sample"? You may be confused on how the SVM function accepts its training data. Here's a quick example of how I use it:

首先,让我们使用 fitcsvm 使用500个样本训练SVM模型随机数据(训练数据矩阵中的行),每个都有1000个元素(训练数据矩阵中的列),其中前250个样本在第1类(前250行训练标签),最后250个样本属于0级(最后250行培训标签):

First, lets train an SVM model using fitcsvm using 500 samples of random data (the rows in the training data matrix), each with 1000 elements (the columns in the training data matrix), where the first 250 samples are in class 1 (first 250 rows of training labels), and the last 250 samples are in class 0 (last 250 rows of training labels):

>> training_data = rand(500, 1000);
>> training_labels = [ones(250,1); zeros(250,1)];
>> 
>> svm_model = fitcsvm(training_data, testing_data)

svm_model = 

  ClassificationSVM
      PredictorNames: {1x1000 cell}
        ResponseName: 'Y'
          ClassNames: [0 1]
      ScoreTransform: 'none'
     NumObservations: 500
               Alpha: [418x1 double]
                Bias: 2.3217
    KernelParameters: [1x1 struct]
      BoxConstraints: [500x1 double]
     ConvergenceInfo: [1x1 struct]
     IsSupportVector: [500x1 logical]
              Solver: 'SMO'


  Properties, Methods

我们可以为10个测试样本生成一些随机测试数据,每个样本有1000个元素,并且从中创建一些预测:

We can generate some random test data for 10 test samples, each with 1000 elements, and create some predictions from it:

>> test_data = rand(10, 1000);
>> predicted_classes = predict(svm_model, test_data)

predicted_classes =

     1
     1
     1
     1
     1
     0
     0
     0
     1
     0

这会回答你的问题吗?

这篇关于如何使HOG特征向量适应线性svm输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆