自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 paddlepaddle异步读取数据+保存模型-只有关键代码

paddle异步数据读取实战

2022-07-25 16:08:07 489 1

原创 cos_sim的详细计算过程

@[Tcos_sim的详细计算过程$$`cos_sim的详细过程x1 = np.arange(4).reshape(2,2).astype('float32')x2 = np.arange(1,5).reshape(2,2).astype('float32')w12 = np.sum(x1 * x2, axis=1)w1 = np.sum(x1 * x1, axis=1)w2 = np.sum(x2 * x2, axis=1)eps=1e(-8)n12 = np.sqrt(np.clip(w

2020-11-01 18:13:45 1558

原创 python利用keras搭建BP网络拟合

from sklearn import preprocessingfrom keras.models import Sequentialimport numpy as npimport matplotlib.pyplot as pltfrom keras import modelsfrom keras import layersfrom keras import optimizers...

2019-05-30 21:57:59 2289

原创 Python利用主流框架tensorflow搭建BP网络拟合

主要参考了莫烦老师的一些程序,感觉主要是将数据进行归一化,特别是y的数值进行归一化,不然训练的过程中loss降不下去tensorflow# -*- coding: utf-8 -*-"""Created on Thu Nov 8 11:56:47 2018@author: Administrator"""# -*- coding: utf-8 -*-import tensor...

2019-05-30 21:54:19 543

原创 pytorch训练结果的复现设置随机种子

通过设置全局随机种子使得每次的训练结果相同可以复现def seed_torch(seed=2018): random.seed(seed) os.environ['PYTHONHASHSEED'] = str(seed) np.random.seed(seed) torch.manual_seed(seed) torch.cuda.manual_seed...

2019-04-18 09:43:55 8327 2

原创 matlab绘制双坐标图并且绘制柱状图

clear all;clc;close all;x = [1,2,3,4,5,6];y1 = [6,6,6,0,0,0];x2 = [2,4,6];y2 = [0,0,0,420,180,50];figure;[AX,H1,H2] = plotyy(x,y1,x,y2,'bar','bar')set(H1,'BarWidth',0.5,'FaceColor',[0.69 0....

2019-03-08 12:54:21 9031

原创 win7系统CPU环境下利用YOLOv3搭建目标检测系统python(keras)

写这个博文的目的是我做这个的时候参考了很多其他博主的文章,但是都是只有进行图片检测的,没有视频检测的,而视频检测官网也说的不是很清楚,这里贴出来具体步骤供大家参考首先是从github网站https://github.com/qqwweee/keras-yolo3上下载clone项目到你的文件夹那个data文件是我自己新建的,里面放置了测试图片和测试视频,yolov3.weights是后来自己...

2019-03-01 20:28:37 1488

原创 import cv2报错numpy.core.multiarray failed to import

出现这个问题的解决方法是下载最新版本的numpy,下载网址如下:https://www.lfd.uci.edu/~gohlke/pythonlibs然后放到C:\Users\Administrator\Anaconda3\Lib\site-packages,这是我的安装路径,每个人的不一样,看情况。然后进入anaconda的prompt命令框,先卸载原来的numpy就是pip uninsta...

2019-03-01 17:26:53 2475 2

原创 leetcode--Partition Equal Subset Sum分区等子集和问题

第一种解法dp[j] = dp[j] || dp[j - nums[i]] (nums[i] <= j <= target)class Solution {public: bool canPartition(vector<int>& nums) { int sum = accumulate(nums.begin(), ...

2019-02-24 12:27:30 199

原创 python中的PIL的img.show()函数显示不了图像

我的报错是弹出窗口,提示没有关联程序网上的解决方法是修改安装包里面的代码,但是我修改了也没用,后来参照 世间的盐博主方法,先将图片另存为bmp模式,然后右键这个图片,然后选择默认打开程序为图片查看器或者画图板,这时重新运行程序就能用了...

2019-02-24 11:04:32 3430 1

原创 pytorch在pycharm中没有代码自动提示的解决办法

我安装的是pytorch1.0,安装后代码提示不完整,就是比如一些tensor.mean(),tensor.sum(),x.grad()等没有自动提示功能,上网搜了一遍,发现知乎上的孟paper同学的解决方法比较好,但是他贴出来的连接由于墙的限制进不去,所以我把那个init.pyi文件放在百度网盘中,便于大家下载import sitesite.getsitepackages()找到’C:...

2019-02-23 19:10:25 5590 8

原创 python中字典的遍历

dicts ={'name':['earth','moon'],'port':[90,80,70]}for v in dicts.items(): print(v)print()for key,value in dicts.items(): print('key is:',key,'value is',value)print()for v in dicts.values(...

2019-01-15 21:22:25 444

原创 sigmoid的前向传播以及loss函数计算,后向传播的梯度计算

cs231n只给出了softmax的传播梯度计算,所以自己试着写了sigmoid,此处自己写的sigmoid的后向传播梯度只适用于2分类,且标签为[0,1,0,1…]这种列表形式,后向梯度计算时利用CS231N的梯度校验函数算出来的梯度和自己算的梯度总是相差2倍关系,最后发现可能是计算是将1标签和0标签的损失都算了一遍,多算了一次,相当于数据量为2Nimport numpy as npimp...

2019-01-04 17:09:55 2041

原创 matlab编程修改图片大小以及坐标轴的数字大小

x = 0:1/1000:2;y = sin(x*pi);figure;plot(x,y)xlabel('t/s','FontName','Times New Roman','FontSize',10);%%设置坐标轴名称的字体大小ylabel('A/V');title('电压');set(gcf,'unit','centimeters','position',[10 8 7 5])%...

2018-11-28 19:36:02 6173

原创 结构体数组的排序以及删除

排序的话利用sort,但是要用cmp函数,删除的话只可以覆盖#include<iostream>#include<algorithm>#include<string>using namespace std;struct st{ int a1; string b1;}arr[50];bool cmp(const st &x, con...

2018-11-20 15:31:56 7590 3

原创 C++中map数组的排序,删除某一个值等操作

C++中map数组的排序,删除某一个值等操作#include<iostream>#include<algorithm>#include<stdio.h>#include <vector>#include<string>#include<map>#include <functional> // std:

2018-11-20 11:28:51 1356

原创 python函数编程时的可变长度的参数

#####可变对象def change(mylist): for i in mylist: print(i*i,end=" ") mylist=[1,2,3]change(mylist)#####非关键字可变参数(元祖)和关键字可变参数(字典)def newfoo(arg1,arg2,*nkw,**kw): print("arge1 i...

2018-10-09 14:51:11 289

原创 添加运算符使其和等于某一个数

比如小米的笔试题,给定1~n,在其中插入加减或空格,空格代表连接两个相邻数字,求表达式和为m的个数n,m = map(int, raw_input().split()) count = [0] def dfs(i,s): if i == n: if m == eval(s): count[0] += 1 else: ...

2018-10-09 09:29:50 474

原创 python隔板法在字符串的不同位置插入标点符号

输入字符串,指定k为添加的标定符号的个数,比如在1111这个字符串的中间添加2个逗号,应该是3种情况,用程序表示就是ss=str(input())count=[0]res=[]k=0def dfs(i,s,k): if(i==len(ss)): if(k==2): res.append(s) else: dfs(i...

2018-10-08 22:32:54 1379

原创 二叉树的两个节点的最近公共祖先leetcode

从根节点开始遍历,如果p和q中的任意一个和root匹配,则root就是最低公共选,如果不匹配,分别左右递归左右子树,如果有一个节点出现在左子树,另外一个出现在右子树,则root就是最低公共祖先,如果节点都出现在左子树,则最低公共祖先出现在左子树,否则在右子树/** * Definition for a binary tree node. * struct TreeNode { * ...

2018-09-29 11:38:31 1132

原创 二叉树的宽度计算

面试的时候问到了二叉树的宽度,平时做过二叉树的深度,这个其实一样,代码如下,利用层序遍历,找到每一层节点数最多的就是数的宽度int treewidth(TreeNode *root){ if(root==NULL) { return 0; } int wid=0; int maxwid=0; queue<TreeNode*>q; q.push(root); wh...

2018-09-29 10:42:56 1536

原创 隔板法切割字符串(必须保证切得的字符串至少有一个字符)

#include<iostream>#include<vector>#include<algorithm>#include<string>using namespace std;void partition(string &s, int start, vector<string> temp, vector<vec...

2018-09-29 10:12:35 232

原创 python中对于重复出现的记录,标记其第一次出现,中间出现,最后一次出现

import numpy as npimport pandas as pd #标记DataFrame重复例子df = pd.DataFrame({'col1': ['one', 'one', 'two', 'two', 'two', 'three', 'four'], 'col2': [1, 2, 1, 2, 1, 1, 1], 'col3':['AA'...

2018-09-28 17:30:41 4583

原创 判断字符串能组成多少个有效的ip地址leetcode

给定一个字符串,通过加入三个点,看能组成多少个有效的ip#include<iostream>#include<vector>#include<string>#include<algorithm>#include<sstream>using namespace std;bool isvalidip(string s){...

2018-09-28 16:39:15 1584

原创 python进行一维数组和二维数组的输入

二维数组的输入n=int(input())a=[]for _ in range(n): a.append(list(map(int,input().split(' '))))print(a)一维数组的输入########一维数组的输入3a=list(map(int,input().split(' ')))print(a)...

2018-09-26 22:44:55 1769

原创 python正则表达式进行字符串的查找

python进行字符串的查找,查找出现的位置import re####列表返回pattern=re.compile(r'\d+')re1=pattern.findall('run 123 and 456')print(re1)######迭代器返回it=re.finditer(r'\d+','12ab32bc43jf45')for match in it: print(ma...

2018-09-26 22:23:37 8238

原创 C++进行输入字符串的分割

常见的编程时输入一个字符串,以逗号或者空格隔开,存到一个数组里面,利用getline进行分割,但是要加头文件<sstream.h>vector<vector<string>ad;int k=3;while(k--){string s1;getline(cin,s1);vector<string>res;string s;stringstr...

2018-09-24 20:51:35 2333

原创 C++利用正则表达式进行字符串的替换

主要要加上头文件#inlcude,这也是剑指offer上的题目void replaceSpace(string str,int length) { string pattern=" "; regex re(pattern); string fmt="20%"; string ret=regex_replace(st...

2018-09-24 20:32:52 4841 1

原创 C++中查找字符串中子串出现的位置以及次数

加上begin=begin+p.length()后,是将第一个子串跳过然后查找,结果如下,其中T=“111231123”,P=“11”string T;//原串string P;//模式cin>>T>>P;int count=0;int begin=-1;while((begin=T.find(P,begin+1))!=string::npos){ coun...

2018-09-24 20:18:15 23048 1

原创 二分法返回有序数组的上界和下界,旋转数组最小值

#include<iostream>#include<vector>#include<algorithm>using namespace std;int lower_pos(vector<int>&array,int target){ int left=0; int right=array.size()-1; ...

2018-08-18 11:44:14 430

原创 单链表和双链表的反转

单链表和双链表的反转总结#include<iostream>#include<vector>using namespace std;struct singlenode{ int value; singlenode *next;};struct doublenode{ int value; doublenode *pre,...

2018-08-11 11:28:55 260

原创 C++二维不定长数组的输入

c++编程题目中的二维不定长数组vector的输入#include<iostream>#include<vector>#include<algorithm>#include<string>using namespace std;int main(){ int N,m; cin&gt

2018-08-05 22:49:38 4893

空空如也

空空如也

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

TA关注的人

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