自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(198)
  • 收藏
  • 关注

原创 Machine_Learning(logistic回归习题:matlab版)

logistic回归习题:matlab版线性可分ex2.mclose all;clear all;clc;data = load('E:\ML_exercise\ex2\ex2data1.txt');X=data(:,1:2);y=data(:,3);%plotData(X,y);m=length(y);X=[ones(m,1),X];theta = zeros(3,1);init_cost = costFunction(X,y,theta)options = optimset(

2020-08-12 20:48:48 429

原创 《MATLAB图像处理实例详解》:CH_7(图像分割技术)

图像分割技术①提取线段close all;clear all;clc;I=imread('E:\Matlab_exercise\图片素材\xianduan.jpg');I=rgb2gray(I);h1=[-1 -1 -1;2 2 2;-1 -1 -1];%横线h2=[-1 -1 2;-1 2 -1;2 -1 -1];%45°斜线h3=[-1 2 -1;-1 2 -1;-1 2 -1];%竖线h4=[2 -1 -1;-1 2 -1;-1 -1 2];%135°斜线J1=imfilter(I,

2020-08-12 10:42:38 708

原创 Machine_Learning(logistic回归习题:python版)

logistic回归习题:python版线性可分import numpy as npimport pandas as pdimport matplotlib.pyplot as pltdata = pd.read_csv('E:\ML_exercise\ex2\ex2data1.txt',names=['Exam1','Exam2','Accepted'])data.head()①数据可视化fig,ax = plt.subplots()ax.scatter(data[data['Ac

2020-08-11 18:54:32 387

原创 《MATLAB图像处理实例详解》:CH_6(图像复原技术)

图像复原技术一、常见噪声1.高斯噪声(gaussian)、椒盐噪声(salt&pepper)、均匀分布噪声、指数分布噪声、伽马分布噪声2.添加噪声:imnoise(I,type,parameters);高斯噪声close all;clear all;clc;I=uint8(100*ones(256,256));J=imnoise(I,'gaussian',0,0.01);%高斯噪声,均值为0,方差为0.01K=imnoise(I,'gaussian',0,0.03);figure;

2020-08-11 11:42:27 629

原创 《MATLAB图像处理实例详解》:CH_5(图像增强技术)

图像增强技术空域内增强①灰度变换增强close all;clear all;clc;I=imread('E:\Matlab_exercise\图片素材\grayBeauty.jpg');I=double(I);J=(I-80)*200/100;row=size(I,1);column=size(I,2);for i=1:row for j=1:column if J(i,j)<0; J(i,j)=0; end

2020-08-11 09:57:31 384

原创 Machine_Learning(第七章)

logistic 回归假设函数决策边界:假设本身和参数的属性,不是训练集的属性代价函数简化的代价函数梯度下降算法多分类问题欠拟合:没有很好的拟合训练数据过拟合:假设函数能拟合几乎所有数据,但函数可能太过庞大,变量太多正则化:避免过拟合线性回归的正则化正则化梯度下降正则化正规方程逻辑回归的正则化正则化梯度下降...

2020-08-09 16:34:18 121

原创 《MATLAB图像处理实例详解》:CH_4(领域操作)

领域操作滑动邻域操作函数:nlfilter()列方向邻域操作函数:colfilt()分离邻域操作函数:blockproc()close all;clear all;clc;I=imread('E:\Matlab_exercise\图片素材\beauty.jpg');fun=@(block_struct) imrotate(block_struct.data,30);%获取分离块操作的函数句柄I1=blockproc(I,[64 64],fun);%进行分离块操作fun=@(block_st

2020-08-09 10:59:49 373

原创 《MATLAB图像处理实例详解》:CH_4(空间变换)

空间变换函数:intransform()仿射变换(平移、缩放、旋转、剪切)、投影变换(x’,y’)=T(x,y)x’=a0x+a1y+a2y’=b0x+b1y+b2

2020-08-09 10:22:49 428

原创 Machine_Learning(线性回归习题:matlab版)

线性回归习题:matlab版一、单变量线性回归ex1.mdata=load("E:\ML_exercise\ex1\ex1data1.txt");x=data(:,1);y=data(:,2);plotData(x,y,data);%predictpredict1 = [1, 3.5] *theta;fprintf('population = 35,000, profit = %f\n',predict1*10000);predict2 = [1, 7] * theta;fprint

2020-08-08 15:07:37 180

原创 《MATLAB图像处理实例详解》:CH_4(灰度变换)

《MATLAB图像处理实例详解》:CH_4灰度变换imadjust函数close all;clear all;clc;gamma=0.5; %设定调整线性度取值I=imread("E:\Matlab_exercise\图片素材\lian2.jpg");R=I;R(:,:,2)=0; %设定第二通道绿色为0R(:,:,2)=0; %设定第三通道蓝色为0,只保留红色R1=imadjust(R,

2020-08-08 11:29:10 309 1

原创 《MATLAB图像处理实例详解》:CH_3

《MATLAB图像处理实例详解》:CH_3一、图像类型转换:①RGB图像转换为灰度图像:I=imread("E:\Matlab_exercise\图片素材\lian.jpg");#读取图片X=rgb2gray(I);#RGB图像转换为灰度图像figure;#显示图像subplot(121);imshow(I);subplot(122);imshow(X);②RGB图像转换为索引图像:RGB=imread("E:\Matlab_exercise\图片素材\lian2.jpg");#读取图

2020-08-08 10:39:11 361 1

原创 Machine_Learning(线性回归习题:python版)

第六章习题①创建一个ex1.txt文件,内容为eye(5)②文件重命名为ex1.m,在octave中将当前路径改为文件ex1.m的路径下③octave中输入run(‘ex1.m’)

2020-08-06 16:12:16 279

原创 python基础知识学习(异常处理结构)

异常处理结构捕获一种异常try: try块except Exception [as e]: except 块try: try块except Exception [as e]: except 块finally: //不管有没有异常都执行try: try块except BaseException[as e]: //可以捕获所有异常(不精准) except 块例:while True: x = input('please input an Integer:') try:

2020-07-30 15:45:52 234

原创 python基础知识学习(文件操作)

文件操作打开、读写、关闭open(filename, mode=‘r/w/a…’, buf = -1, encoding=‘GBK /utf8…’ …)打开成功:返回可迭代对象打开失败:抛出异常filename.close()with关键字:with open( ) as fpeg.with open('test.txt','r') as src, open('test_new.txt', 'w') as dst:dst.write(src.read()) #【write() 只能写

2020-07-29 16:58:09 154

原创 python基础知识学习(面向对象程序设计)

面向对象程序设计pass关键字,保留功能,以后实现(可在类、函数、选择结构中使用)self参数,所有实例方法必须有的,且为第一个形参,相当于C++的this指针mixin机制,可动态为自定义类及其对象增加新的属性和行为两个下划线“__”或更多下划线开头而不以两个或多个下划线结束表示为类的私有成员【私有成员在类的外部不能直接访问,可通过公开成员方法或特殊方式访问】特殊方式:对象名.类名 成员名(不存在严格意义上的私有成员)一个下划线""开头不以下划线结束为受保护成员两个下划线“

2020-07-22 16:41:30 136

原创 python基础知识学习(正则表达式)

正则表达式一、re模块(import re)re.split(‘分隔符’,str)— re.split(’[. ]+’,str)以.或空格为分隔符re.findall(表达式,str)— pat = ‘[a-zA-Z]+’re.findall(pat,text)查找str中所有符合条件的表达式re.sub(‘原串’,‘替换串’,str)— re.sub(‘a|s|d’,‘good’,str)将str中的a/b/d替换为goodre.sub(’[a|e]’,lambda x:x.group(

2020-07-18 16:12:25 120

原创 python基础知识学习(字符串)

python学习(字符串)常用方法:①查找子串s.find(“str”,form,to)在s字符串中,从下标from到to查找字符串str,找到返回起始下标,否则返回-1(from/to可选)s.rfind(“str”)在s字符串中,反向查找str首次出现的位置s.index(“str”)在s字符串中,查找str首次出现的位置,未查到则抛出异常s.rindex(“str”)在s字符串中,反向查找str首次出现的位置s.count(“str”)统计str在s中出现的次数②分割s.s

2020-07-18 14:08:42 204

原创 Python基础知识学习(元组、序列解包、字典、集合)

元组、序列解包、字典一、元组元组为不可变序列①tuple() 将序列转换为元组②del() 删除元组,不能删除元组中的元素【注】当元组中包含列表等可变序列时,此时可变序列可变化二、序列解包①print([1,22,3],4,[5,6])②*range(4),4三、字典无需可变序列,{key:value}创建空字典:dictionary = {} 或 dictionary = dict()del删除整个字典访问字典:dictionary[key]返回该key对应的value,不

2020-07-15 15:10:01 259

原创 Python基础知识学习(列表)

序列一、在列表中增加元素①list = list + [x] 将原有list中的元素复制后+x,改变list首地址list = list * 3 list元素重复三遍,得到新的list②list.append(x) 原地操作,不改变list首地址③list.extend([x,y,z]) 新的列表元素增加到list中,原地操作,不改变list首地址④list.insert(index,x) 在指定下标index处添加元素x,元素移动,速度慢二、在列表中删除元素①del list[in

2020-07-12 16:07:33 1547

原创 Machine_Learning(第二章)

Chapter_2代价函数hypothesis:θ0、θ1为参数cost function:m为样本数量,i为第i个样本goal:找到(θ0,θ1),使J(θ0,θ1) 最小梯度下降同时更新 θ0,θ1

2020-07-12 10:43:22 131

原创 Machine_Learning(第一章)

Chapter_1supervised learning数据已经有“right answer”①classification(分类)— predict real-valued(具体数值) output②regression(回归) — predict discrete-valued(离散数值,0,1,2…) outputunsupervised learning只有数据,通过算法将数据分簇...

2020-07-11 10:30:55 92

原创 Python基础知识学习(基本语法)

①函数:打印:print(“I Love China!”)----括号必须加,不加分号;输入:input()随机数:randint() 返回一个随机整数(import random)eg:import randomnum = random.randint(1,10)整形:int()浮点型:float()字符串:str()查看变量类型:type()、isinstance(变量名,变量类型)----返回布尔类型生成从from到to-1的数,步进为step:range(from,to,st

2020-07-10 19:37:26 209

原创 学习:图的存储(领接表和领接矩阵)

学习:图的存储(领接表和领接矩阵)#include <iostream>#include <cassert> #include <ctime>#include <cstdlib>#include <vector>using namespace std;//稀疏图 - 领接表class SparseGraph{private: int n,m;//顶点个数、边的2 bool directed;//是否为有向图 vector

2020-05-12 15:41:07 785

原创 学习:数组原地堆排序(从小到大排序)

学习:数组原地堆排序(从小到大排序)#include <iostream>#include <ctime>#include <cstdlib>using namespace std;template <class T>void shiftDown(T a[], int k, int n){ while( 2*k <= n) { int j=2*k; if(j+1 <= n && a[j+1] > a

2020-05-09 17:32:52 459

原创 学习:堆排序(大顶堆)

学习:堆排序(大顶堆)#include <iostream>#include <cassert>#include <ctime>#include <cstdlib>using namespace std;template <class T>class MaxHeap{ private: T *data; int count; int capacity; void shiftUp(int k) {

2020-05-09 16:49:13 121

原创 学习:三路快速排序

学习:三路快速排序#include <stdio.h>void swap(int *a, int *b){ int t=*a; *a=*b; *b=t;}//三路快排,a[l...lt-1]<pivot,a[lt...gt-1]=pivot,a[gt...r]>pivotvoid __quickSort(int a[], int l, int r){ int lt=l,gt=r+1,i=l+1,pivot=a[l]; if(l >= r) re

2020-05-08 18:06:12 162

原创 学习:快速排序(简单版)

学习:快速排序(简单版)此版本不适用于有大量重复值和数据基本有序的数据进行快速排序。#include <stdio.h>//交换void swap(int *a, int *b){ int t=*a; *a=*b; *b=t;}//划分数组:a[l...j-1]<pivot, a[j]==pivot, a[j+1...r]>=vint partition(int a[], int l, int r){ int i,j=l,pivot=a[l]; for(

2020-05-08 17:38:03 147

原创 学习:归并排序(MergeSort)

学习:归并排序(MergeSort)C语言版:#include <stdio.h>#include <stdlib.h>//自底向上合并void __merge(int a[], int l, int mid, int r){ int *temp,i,j,k; temp=(int*)malloc(sizeof(int)*(r-l+1)); for(i=l;...

2020-05-07 15:23:21 114

原创 PTA(Basic Level) 1013:数素数(C语言实现)

PTA(Basic Level) 1013:数素数(C语言实现)#include <stdio.h>int isPrime(int n){ int i; if(n < 2) return 0; if(n == 2) return 1; if(n%2 == 0) return 0; for(i=3; i*i<=n; i++) if(n%i == 0) ...

2020-05-07 14:45:41 246 1

原创 PTA(Basic Level) 1012:数字分类(C语言实现)

PTA(Basic Level) 1012:数字分类(C语言实现)#include <stdio.h>int main(){ int num,sum1=0,sum2=0,count1=0,count2=0,count3=0,max=-1,sign=1; double sum3=0,ave; int n,i=1; scanf("%d",&n); while(n...

2020-05-07 14:13:59 240

原创 PTA(Basic Level) 1011:A+B 和 C (C语言实现)

PTA(Basic Level) 1011:A+B 和 C (C语言实现)#include <stdio.h>int main(){ long a,b,c;//a,b,c的范围 int n,i=1; scanf("%d",&n); for(i=1; i<=n; i++) { scanf("%ld%ld%ld",&a,&b,&...

2020-05-07 14:11:41 240

原创 PTA(Basic Level) 1010:一元多项式求导 (C语言实现)

PTA(Basic Level) 1010:一元多项式求导 (C语言实现)#include <stdio.h>int main(){ int a,ex,flag=0; while(scanf("%d%d",&a,&ex) != EOF) { if(ex!=0) { flag==0?printf("%d %d",a*ex,ex-1):print...

2020-05-07 13:57:12 380

原创 PTA(Basic Level) 1009:说反话 (C语言实现)

PTA(Basic Level) 1009:说反话 (C语言实现)#include <stdio.h>#include <string.h>int main(){ int i,l,j; char s[81]=""; gets(s); l=strlen(s); for(i=l-1; i>=0; i--) { if(s[i] != ' ' &amp...

2020-05-06 18:15:43 317

原创 PTA(Basic Level) 1008:数组元素循环右移问题(C语言实现)

PTA(Basic Level) 1008:数组元素循环右移问题(C语言实现)#include <stdio.h>int main(){ int n,m,i,j,t,a[100]={0}; scanf("%d%d",&n,&m); m%=n; for(i=0; i<n; i++) scanf("%d",&a[i]); for(i=0;...

2020-05-06 18:00:27 292

原创 PTA(Basic Level) 1007:素数对猜想(C语言实现)

PTA(Basic Level) 1007:素数对猜想(C语言实现)#include <stdio.h>int isPrime(int n){ int i; if(n < 2) return 0; if(n == 2) return 1; if(n%2 == 0) return 0; for(i=3; i*i<=n; i++) if(n%i == 0)...

2020-05-06 17:53:52 205

原创 PTA(Basic Level) 1006:换个格式输出整数(C语言实现)

PTA(Basic Level) 1006:换个格式输出整数(C语言实现)#include <stdio.h>int main(){ int i,n,g,s,b; scanf("%d",&n); g=n%10; s=n/10%10; b=n/100; for(i=0; i<b; i++) putchar('B'); for(i=0; i<s...

2020-05-06 17:46:42 189

原创 L1-025 正整数A+B(C语言实现)

L1-025 正整数A+B(C语言实现)注意:a和b的值范围为[1,1000]。#include <stdio.h>#include <ctype.h>int main(){ int a=0,b=0,flag=0; char ch; while((ch=getchar()) != '\n') { if(!flag)//第一个数字 { if(i...

2020-05-03 16:26:32 960

原创 L1-023 输出GPLT(C语言实现)

L1-023 输出GPLT(C语言实现)#include <stdio.h>#include <ctype.h>int main(){ char ch; int g=0,p=0,l=0,t=0; while((ch=getchar()) != '\n') { ch=toupper(ch); if(ch == 'G') g++; else if(c...

2020-05-03 15:59:11 306

原创 L1-020 帅到没朋友(C语言实现)

L1-020 帅到没朋友(C语言实现)#include <stdio.h>int main(){ int n,m,k,i,j,id,flag[100000]={0},count=0; scanf("%d",&n); for(i=0; i<n; i++) { scanf("%d",&k); for(j=0; j<k; j++) {...

2020-05-03 15:48:24 701

原创 L1-006 连续因子(C语言实现)

L1-006 连续因子(C语言实现)参考链接:添加链接描述#include <stdio.h>#include <math.h>int main(){ int n,i,j,count=0,first=0,maxn,temp; scanf("%d",&n); maxn=sqrt(n)+1; for(i=2; i<=maxn; i++) { ...

2020-05-02 15:59:00 1076

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除