GT

Introduction to Support Vector Machines

耗尽温柔 提交于 2020-03-24 08:28:26
3 月,跳不动了?>>> Goal In this tutorial you will learn how to: Use the OpenCV functions cv::ml::SVM::train to build a classifier based on SVMs and cv::ml::SVM::predict to test its performance. What is a SVM? A Support Vector Machine (SVM) is a discriminative classifier formally defined by a separating hyperplane. In other words, given labeled training data ( supervised learning ), the algorithm outputs an optimal hyperplane which categorizes new examples. In which sense is the hyperplane obtained optimal? Let's consider the following simple problem: For a linearly separable set of 2D-points which

正态贝叶斯分类器CvNormalBayesClassifier的OpenCV4.0多个实例代码实战

旧巷老猫 提交于 2020-03-24 08:28:08
3 月,跳不动了?>>> 说明 OpenCV中实现的正态贝叶斯分类器Normal Bayes Classifier,而不是其他类型的贝叶斯分类器,例如朴素贝叶斯分类器Naive Bayes Classifier。 正态贝叶斯分类器中样本特征属性之间不必是相互独立的,因而适用范围更广,但是只能处理特征属性是连续数值的分类问题 。 源码 实例1 根据身高体重脚长预测性别 题例 例子是维基百科中英文条目Naive Bayes classifier所列举的例子。下表是某国人体特征指标的一组统计资料: 问题是,已知某人身高6英尺,体重130磅,脚掌长8英寸,利用前面的训练样本来预测该人是男还是女。 实现 // NormalBayes.cpp : 定义控制台应用程序的入口点。 // #include "stdafx.h" #include "opencv2/opencv.hpp" #include "opencv2/ml.hpp" #include <iostream> using namespace cv; using namespace cv::ml; using namespace std; void main(int argc, char** argv) { //创建正态贝叶斯分类器 Ptr<NormalBayesClassifier> model =

OpenCV笔记(4)实现神经网络(ANN)

一曲冷凌霜 提交于 2020-03-24 08:27:47
3 月,跳不动了?>>> 1.神经网络 神经网络最重要的功能是 分类 ,前面用opencv实现的SVM也是 分类器 。 分类器的输入是数值向量,输出是数值。目标是让正确分类的比例尽可能高。一般我们需要建立训练样本,标记好分类结果,用这些标记好的数据去训练分类器,训练好的分类器就可以在新来的特征向量上预测。 下面是一些样本: 若是将其分开,只需要画出一条直线,如下所示: 再来的新的向量,落到左边就是蓝球,在右边就是红球,这样就实现了一个简单的分类器。这个分类器被称为神经元。直线的方程我们可以写出来: 。等式左边大于0还是小于0决定点在直线的哪一侧。 神经元的一个问题是只能分类一次,如果出现下面这种情况,就没有办法画一条直线将其分开,我们的解决办法是使用多层神经网络。 在多层神经网络之中,低层的神经元的输出是高层神经元的输入。上图我们可以分别用几条直线将其割开,再重新组合。这里每使用一条直线就是一个神经元,神经元之间依次连接,就能达到分类的目的。 神经网络的工作与人脑中的神经元有着很大的相似,每一个神经元都有若干神经元作其输入,而且自身也是另外神经元的输入,数值向量就像电信号,在不同神经元之间传导,每一个神经元只有满足了一定条件才会发射信号到下一层神经元。当然,人脑比人工神经网络要复杂的多。 神经网络的训练依靠反向传播算法 ,最开始的输入层输入特征向量,网络层计算得到输出

tf.convert_to_tensor()函数的使用 | 数据类型转换

浪尽此生 提交于 2020-03-24 08:21:31
3 月,跳不动了?>>> #将python的数据类型(列表和矩阵)转换成TensorFlow可用的tensor数据类型 import tensorflow as tf import numpy as np A = [1,2,3] B = np.array([1,2,3]) C = tf.convert_to_tensor(A) D = tf.convert_to_tensor(B) print(type(A), A) print(type(B), B) print(type(C), C) print(type(D), D) 结果 <class 'list'> [1, 2, 3] <class 'numpy.ndarray'> [1 2 3] <class 'tensorflow.python.framework.ops.EagerTensor'> tf.Tensor([1 2 3], shape=(3,), dtype=int32) <class 'tensorflow.python.framework.ops.EagerTensor'> tf.Tensor([1 2 3], shape=(3,), dtype=int32) 点赞 收藏 分享 文章举报 阿卡基猿 发布了230 篇原创文章 · 获赞 192 · 访问量 60万+ 他的留言板 关注 来源: oschina 链接:

Tensorflow object detection API 安装过程中出现的一些问题

流过昼夜 提交于 2020-03-24 08:21:06
3 月,跳不动了?>>> $ python object_detection/builders/model_builder_test.py Traceback (most recent call last): File "object_detection/builders/model_builder_test.py", line 23, in <module> from object_detection.builders import model_builder File "D:\tensorflow\models\research\object_detection\builders\model_builder.py", line 22, in <module> from object_detection.builders import box_predictor_builder File "D:\tensorflow\models\research\object_detection\builders\box_predictor_builder.py", line 20, in <module> from object_detection.predictors import convolutional_box_predictor File "D:\tensorflow\models

EOJ 3497/EOJ Monthly 2018.2 D.黑心的出租车

余生颓废 提交于 2020-03-24 08:01:44
3 月,跳不动了?>>> 题目简介 给定一个树/森林,从1号点出发,遍历森林中所有的点最后回到1号点。 大巴可以在有边相连的两点间往返,而出租车可以在任意两点间往返。 要求:乘出租车次数最少的情况下,乘大巴次数也最少,求两个次数。 说明 官方题解: 因为题目保证无环,因此必为树或森林。 当图为一棵树时,答案为 0,2(n−1)。 当图为森林时,出租车次数判一下联通块即可,其实答案就是 n−m。而巴士站数,对于每个联通块,需要 2 倍边的数量减去树的直径,然后求和即可。 注意慎用 memset,初始化仅需 DFS 所需要用的点,不然会 TLE。 #include <bits/stdc++.h> using namespace std ; const int maxn = 1e5 + 5 ; int dep[maxn]; vector < int > g[maxn]; bool vis[maxn]; inline void dfs( int x, int & root, int y= 0 ) { dep[x] = dep[y]+ 1 ; vis[x] = 1 ; if (dep[x] > dep[root]) root = x; for ( auto i: g[x]) { if (i == y) continue ; dfs(i, root, x); } } int main() {

洛谷1006 传纸条

笑着哭i 提交于 2020-03-24 08:00:50
3 月,跳不动了?>>> https://www.luogu.org/problemnew/show/P1006 棋盘dp,化双向为单向:视作从左上往右下传两张纸条且路劲不重复。 又由于只能向右或向下传递,所以两张纸条过程中必定处于同一斜线上,即横纵坐标之和相等。这样就得到了降维的关键。 用dp[s][i][j]表示纸条1走到第i行,纸条2走到第j行时的最大好心程度,那么方程也不难推得了。 #include <cstdio> #include <algorithm> #define N 51 using namespace std ; int a[N][N], dp[N * 2 ][N][N]; int main( void ) { int i, j, s, m, n, tmp; scanf ( "%d%d" , &m, &n); for (i = 1 ; i <= m; ++i) for (j = 1 ; j <= n; ++j) scanf ( "%d" , &a[i][j]); for (s = 3 ; s <= m + n; ++s) for (i = 1 ; i <= min(s - 1 , m); ++i) for (j = 1 ; j <= min(s - 1 , m); ++j){ if (i == j) tmp = a[i][s - i]; else tmp =

Java大牛养成记——图片上传

耗尽温柔 提交于 2020-03-24 08:00:35
3 月,跳不动了?>>> 背景:感觉过了好久没有好好的写文章了,今天休息就来整理一下最近接触到的内容吧。顺便梳理一下学习到的知识。今天需要梳理的内容是图片的上传。 一、前期准备 在配置文件中配置你要上传的路径: picture_windows=E\:\\picture\\ picture_linux=/home/picture/ 二、JSP <%@ page contentType="text/html;charset=UTF-8" %> <html> <head> <title>上传图片</title> <meta name="decorator" content="default"/> <script type="text/javascript"> $(document).ready(function() { $("#name").focus(); $("#inputForm").validate({ submitHandler: function(form){ loading('正在提交,请稍等...'); form.submit(); }, errorContainer: "#messageBox", errorPlacement: function(error, element) { $("#messageBox").text("输入有误,请先更正。"); if

程序设计能力实训 资料准备

邮差的信 提交于 2020-03-24 07:59:10
3 月,跳不动了?>>> 其实差不多就是模板集合,如果来得及会加上一些库函数的使用方法……EOJ上已故的10175101282Mercury的Blog里面包含的这里就不重复写了。其实主要都是数论相关。 注意:C++限定。 高精度 //加法(非负) inline string add( string s1, string s2) { string s; int len1 = s1.size(), len2 = s2.size(); if (len1 < len2) for ( int i = 1 ; i <= len2-len1; ++i) s1 = "0" + s1; else for ( int i = 1 ; i <= len1-len2; ++i) s2 = "0" + s2; len1 = s1.size(); int plus = 0 , tmp; for ( int i = len1- 1 ; i >= 0 ; --i) { tmp = s1[i]- '0' + s2[i]- '0' + plus; plus = tmp / 10 ; tmp %= 10 ; s = char (tmp+ '0' ) + s; } if (plus) s = char (plus+ '0' ) + s; return s; } //减法 inline int cmp( const

EOJ 1418/POJ 2566 Bound Found

给你一囗甜甜゛ 提交于 2020-03-24 07:58:39
3 月,跳不动了?>>> 题目简介 给定一个数列和t,求总和最接近t的一段连续子序列及其和。 说明 由于n达到了1e5不能采用n^2算法,因此考虑用前缀和+尺取法(滑动窗口法/two pointers)降低复杂度。 #include <bits/stdc++.h> using namespace std ; const int maxn = 1e5 + 5 ; const int INF = 0x3f3f3f3f ; struct node { int id, sum; bool operator < ( const node& rhs) const { if (sum == rhs.sum) return id < rhs.id; return sum < rhs.sum; } }a[maxn]; int n, q, ans, lans, rans; int main() { int x; while ( cin >> n >> q && n+q) { a[ 0 ].id = a[ 0 ].sum = 0 ; for ( int i = 1 ; i <= n; ++i) { scanf ( "%d" , &x); a[i].id = i; a[i].sum = a[i- 1 ].sum + x; } sort(a, a+ 1 +n); while (q--) { scanf (