自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

TH_NUM的博客

有问题知乎私信我哈~~

  • 博客(761)
  • 资源 (10)
  • 收藏
  • 关注

转载 c++ Lambda函数学习

Lambda 表达式算得上是 C++ 11 新增特性中最激动人心的一个。这个全新的特性听起来很深奥,但却是很多其他语言早已提供(比如 C#)或者即将提供(比如 Java)的。简而言之,Lambda 表达式就是用于创建匿名函数的。GCC 4.5.x 和 Microsoft Visual Studio 早已提供了对 lambda 表达式的支持。在 GCC 4.7 中,默认是不开启 C++ 11 特性的...

2018-07-26 09:51:17 327

原创 c++ define 定义工厂函数,使用##连接

c++ define 定义工厂函数,其中define函数名使用##连接# include<stdio.h># include <stdlib.h> //atoi# include <string.h> //strlen# include <stdint.h> //uint64_t#include<iostrea...

2018-07-25 17:27:32 1099

原创 CUDA查询和选取设备信息

CUDA C中的cudaGetDeviceProperties函数可以很方便的获取到设备的信息。#include "cuda_runtime.h"#include "device_launch_parameters.h"#include <iostream>using namespace std;int main(){ cudaDeviceProp dev...

2018-07-25 15:51:16 1780

原创 c++ 智能指针 shared_ptr

# include<stdio.h># include <stdlib.h> //atoi# include <string.h> //strlen# include <stdint.h> //uint64_t#include<iostream>#include&

2018-07-25 14:14:09 224

原创 python 调用C++动态库所遇到的undefined symbol ***

因为算法效率问题所以要在python中调用C, 先写一个C函数:test.cpp # include<stdio.h># include <stdlib.h> //atoi# include <string.h> //strlen# include <unistd.h> //gethostname()# in...

2018-07-24 15:11:55 5485

原创 Open MPI 环境搭建

Open MPI 环境搭建(1)下载和解压wget https://download.open-mpi.org/release/open-mpi/v3.1/openmpi-3.1.1.tar.gztar -zxvf openmpi-3.1.1.tar.gz(2)配置,编译和安装./configure --prefix=/usr/local/openmpimakemake...

2018-07-24 10:01:17 10415 4

原创 MPI函数MPI_Comm_split_type

int MPI_Comm_split_type(MPI_Comm comm, int split_type, int key, MPI_Info info, MPI_Comm *newcomm)INPUT PARAMETERS comm Communicator (handle). split_type Type of...

2018-07-23 17:13:17 2987

原创 MPI Group通信

1.Int MPI_Group_rank(MPI_Group group,int *rank)IN Group 进程组OUT Rank 进程在进程组中的编号 如果进程不是进程组中的成员,则返回值RANK为MPI_UNDEFINED2 . Int MPI_Group_translate_ranks(MPI_Group group1 , int n ...

2018-07-23 16:54:06 1915

原创 c++ 使用tuple和unordered_map

#include<iostream>#include<unordered_map>#include<tuple>using namespace std;int main(){ unordered_map<int,tuple<int,int>> A; tuple<int, int> p1=make_tu...

2018-07-23 10:21:01 1323

原创 nccl 函数 ncclReduce和ncclAllReduce

下面代码中实现了ncclReduce和ncclAllReduce的例子,以ncclReduce举例(其中把隐藏的ncclAllReduce去掉就可以实现ncclAllREduce)://测试NCCL的reduce#include<stdio.h>#include <malloc.h>#include<stdlib.h>#include "cuda_r...

2018-07-20 16:10:28 4808

原创 MPI 函数长度不同的数据分发和聚集 MPI_Scatterv、MPI_Allgatherv

MPI_Scatterv:分发数据 MPI_Allgatherv 不同长度的数据块收集,等价于依次以Comm中的每个进程为根进程调用MPI_Gatherv 或是以任一进程为跟进调用一次普通收集,紧接着再对收集到的数据进行一次广播。#include <stdio.h>#include <stdlib.h>#include <mpi.h>#includ...

2018-07-20 13:51:11 2861

原创 pandas常用用法

1.将DataFrame里面的数值提取成listuserList=list()userList= userList + df1['userID'].values.tolist()2 . 构造含有index的dataFrameactData = pd.DataFrame(index=userList)actData = actData.sort_index()3 . 通过一...

2018-07-19 17:15:34 296

原创 nvidia-nccl 学习

1.ncclResult_t ncclGetUniqueId(ncclUniqueId* uniqueId) 创建一个被初始化函数(ncclCommInitRank)使用的Id。该函数只能被调用一次(在整个分布式计算中只能被一个地方调用),调用后产生的Id需要分发给分布式任务中其他所有的任务,然后在进行ncclCommInitRank初始化操作(该初始化操作需要使用全局统一Id)。comm...

2018-07-18 15:12:47 2218

原创 cuda 在GPU和CPU之间复制数组

int nDev=2; float** sendbuff = (float**)malloc(nDev * sizeof(float*)); float** recvbuff = (float**)malloc(nDev * sizeof(float*)); cudaStream_t* s = (cudaStream_t*)malloc(sizeof(cudaStream_t)*nDe...

2018-07-18 14:58:28 3602

原创 使用nccl 编译运行程序,nccl 的lib出错 undefined reference to `ncclCommInitAll'

undefined reference to ncclCommInitAll' undefined reference toncclGetErrorString’ undefined reference to `ncclGroupStart’需要加载nccl的动态库: 编译方法:nvcc -o first_cuda singleProcess.cpp -I/usr/local...

2018-07-17 22:32:22 2242 1

原创 error: cuda_runtime.h: No such file or directory 和undefined reference to `cudaSetDevice'

使用cuda的gcc编译错误: error: cuda_runtime.h: No such file or directory 和undefined reference to `cudaSetDevice’。解决办法,加载cuda 的lib。 gcc singleProcess.cpp -o singleProcess -L/usr/local/cuda/lib64 -lcudart -...

2018-07-17 22:29:10 6976

原创 c++使用mutex为函数上锁

#ifndef HOROVOD_COMMON_H#define HOROVOD_COMMON_H#include<string.h>#include <string>#include<iostream>#include<memory>//#inlcude<cstring>using namespace std;type...

2018-07-16 13:17:33 1946

原创 Fire() 实现运行单个函数

import firedef main(**kwargs): print("begin input...") for k,v in kwargs.items(): print(k,v)print("hello input")fire.Fire()# if __name__ == "__main__":# fire.Fire()输出:...

2018-07-13 09:39:36 974

原创 Pandas Rank进行排序

排序和排名根据条件对Series对象或DataFrame对象的值排序(sorting)和排名(ranking)是一种重要的内置运算。first: 对于相同的值按照出现的顺序排名 min: 对于相同的值都取小的排名 max:对于相同的值都取大的排名import pandas as pda=pd.DataFrame({'A':[1,2,3],'B':[1,2,3]})#对...

2018-07-11 11:42:35 3037

原创 re.sub 使用方法

re.sub功能是对于一个输入的字符串,利用正则表达式,来实现字符串替换处理的功能返回处理后的字符串re.sub共有五个参数三个必选参数 pattern,repl,string两个可选参数count,flagspattern,表示正则中的模式字符串 反斜杠加数字(\n)表示对应匹配的组也就是用之前匹配到的字符串补充到这个位置,例如将“hello python,ni hao c...

2018-07-11 11:11:46 3843 1

原创 python中defaultdict的用法

当使用普通的字典时,用法一般是dict={},添加元素的只需要dict[element] =value即,调用的时候也是如此,dict[element] = xxx,但前提是element字典里,如果不在字典里就会报错。这时defaultdict就能排上用场了,defaultdict的作用是在于,当字典里的key不存在但被查找时,返回的不是keyError而是一个默认值。例子:from...

2018-07-11 10:57:56 1262

原创 pandas 将多个DataFrame进行groupBy合并

import pandas as pddf = pd.DataFrame({'uid': [1, 2, 3, 4], 'B': [1, 2, 3, 4], 'C': [4,5,6,7]})df2=pd.DataFrame({'uid':[1,1,2,2], 'hello':['...

2018-07-10 20:14:48 5503

原创 pandas 对group进行聚合

DataFrameGroupBy.agg(arg, *args, **kwargs) 例子:>>> df = pd.DataFrame({'A': [1, 1, 2, 2],... 'B': [1, 2, 3, 4],... 'C': np.random.randn(4)})输出:...

2018-07-10 20:04:36 2986

转载 Python RE模块中search()和match()的区别

match()函数只检测RE是不是在string的开始位置匹配,search()会扫描整个string查找匹配;也就是说match()只有在0位置匹配成功的话才有返回,如果不是开始位置匹配成功的话,match()就返回none。例如: print(re.match(‘super’, ‘superstition’).span()) 会返回(0, 5)而print(re.ma...

2018-07-10 19:53:32 558

原创 python类函数__iter__

__iter__:类的迭代器可以使用for循环迭代类例子:##使用genism的word2vecimport os#import gensimclass Mysentences(object): def __init__(self,dirname): self.dirname=dirname def __iter__(self): ...

2018-07-07 14:41:45 2585

原创 python OrderedDict使用

很多人认为python中的字典是无序的,因为它是按照hash来存储的,但是python中有个模块collections(英文,收集、集合),里面自带了一个子类 OrderedDict,实现了对字典对象中元素的排序。 使用dict时,Key是无序的。在对dict做迭代时,我们无法确定Key的顺序。 如果要保持Key的顺序,可以用OrderedDict: 请看下面的实例:import ...

2018-07-05 20:17:03 2724

原创 将字典保存成json 格式文件

将字典保存成json 格式文件:data = dict(d=[1,2],label2id=[3,4],id2label=[5,6])import jsonwith open(outfile,'w') as f: json.dump(data,f)

2018-07-03 23:48:31 14869

原创 tf.contrib.keras.preprocessing.sequence.pad_sequences 将标量数据 转换成numpy ndarray

keras.preprocessing.sequence.pad_sequences(sequences, maxlen=None, dtype=’int32’, padding=’pre’, truncating=’pre’, value=0.) 函数说明: 将长为nb_samples的序列(标量序列)转化为形如(nb_samples,nb_timesteps)2D numpy arr...

2018-07-03 21:50:53 6619

原创 pytorch sampler对数据进行采样

PyTorch中还单独提供了一个sampler模块,用来对数据进行采样。常用的有随机采样器:RandomSampler,当dataloader的shuffle参数为True时,系统会自动调用这个采样器,实现打乱数据。默认的是采用SequentialSampler,它会按顺序一个一个进行采样。这里介绍另外一个很有用的采样方法: WeightedRandomSampler,它会根据每个样本的权重选取数...

2018-07-01 21:32:31 35319 6

转载 pytorch 函数DataLoader

Dataset(https://blog.csdn.net/TH_NUM/article/details/80877196)只负责数据的抽象,一次调用getitem只返回一个样本。前面提到过,在训练神经网络时,最好是对一个batch的数据进行操作,同时还需要对数据进行shuffle和并行加速等。对此,PyTorch提供了DataLoader帮助我们实现这些功能。DataLoader的函数定义如...

2018-07-01 21:23:34 50540 1

原创 pytorch Dataset 的ImageFolder

介绍常用的pytorch Dataset 里面的ImageFolder,实现和https://blog.csdn.net/TH_NUM/article/details/80877196很相似。 ImageFolder假设所有的文件按文件夹保存好,每个文件夹下面存贮同一类别的图片,文件夹的名字为分类的名字。ImageFolder(root,transform=None,target_tr...

2018-07-01 20:57:11 41047 4

原创 pytorch 数据处理:定义自己的数据集合

数据处理版本1#数据处理import osimport torchfrom torch.utils import datafrom PIL import Imageimport numpy as np#定义自己的数据集合class DogCat(data.Dataset): def __init__(self,root): #所有图片的绝对路径...

2018-07-01 20:33:02 11875 1

原创 numpy中array和asarray的区别

array和asarray都可以将结构数据转化为ndarray,但是主要区别就是当数据源是ndarray时,array仍然会copy出一个副本,占用新的内存,但asarray不会。例子1:import numpy as np#example 1:data1=[[1,1,1],[1,1,1],[1,1,1]]arr2=np.array(data1)arr3=np.asarray...

2018-07-01 19:57:36 1241

转载 vim 怎么取消高亮 或取消选中状态

在Vi里面如果要搜索某个关键字,只要键入/xxx就可以了,比如,我要搜索一个函数,我就键入 /snprintf 然后回车,一个文件中,所有出现这个字样的地方都会被高亮显示。按n键,就可以自动把光标跳到下一个。 但是,用好这个功能,怎么消除高亮呢,我以前一直不知道,弄得自己也很无奈。 终于在网上看到,只要键入 :noh 就可以了。...

2018-07-01 10:44:39 7198

原创 pytorch 函数clamp

clamp表示夹紧,夹住的意思,torch.clamp(input,min,max,out=None)-> Tensor将input中的元素限制在[min,max]范围内并返回一个Tensor用法:

2018-06-29 18:19:55 21419

原创 pytorch 常用函数 max ,eq

max找出tensor 的行或者列最大的值:找出每行的最大值:import torchoutputs=torch.FloatTensor([[1],[2],[3]])print(torch.max(outputs.data,1))输出: (tensor([ 1., 2., 3.]), tensor([ 0, 0, 0]))找出每列的最大值:import ...

2018-06-23 13:56:53 25434 1

转载 0.4.0pytorch运行过程中对0-dim和volatile提示UserWarning的解决方法

将pytorch更新到0.4.0最新版后对0.3.1版本代码会有如下警告,它在提醒用户下个版本这将成为一个错误UserWarning: invalid index of a 0-dim tensor. This will be an error in PyTorch 0.5. Use tensor.item() to convert a 0-dim tensor to a Python...

2018-06-23 13:25:25 2580 1

原创 argparse用法

从下面的代码中main.py说明:import argparseparser = argparse.ArgumentParser(description='PyTorch CIFAR10 Training')parser.add_argument('--lr', default=0.1, type=float, help='learning rate')parser.add_argum...

2018-06-23 13:05:28 1161

原创 numpy load、save、savez 将数组或者pickled结构保存在文件中

numpy.load(file, mmap_mode=None, allow_pickle=True, fix_imports=True, encoding=’ASCII’) 示例:将数组保存在文件中,并读取import numpy as npa=np.array([[1, 2, 3], [4, 5, 6],[7,8,9]])b=np.array([1, 2])# np.savez...

2018-06-20 20:10:52 2129

原创 LaTeX:加背景色

设置环境、段落的背景色1.导言区部分,文件头\usepackage{color} %\definecolor{shadecolor}{named}{Gray} \definecolor{shadecolor}{rgb}{0.92,0.92,0.92} \usepackage{framed} 2.文档内容部分begin{shaded} $$ \int_...

2018-06-16 14:07:51 8858

wu-video-js-5.20.1 2.zip

video-js js RTMP video-js js RTMP video-js js RTMP

2019-11-22

ViewWizard

获取窗口的类名和Title.可以使用ViewWizard获取窗口的类名和Title.

2018-10-22

jperf 流量带宽监测

java 实现的perf 流量带宽监测,有图形界面,方便操作。

2017-12-04

PIL win64 for python2.7

python的图形库PIL的windows 64 版本的库,本应该是免费的,但是好像没有免费的选项上传。

2017-12-01

PILwin32 For python 2.7

PILwin32 For python 2.7这是PIl 的32位版本下载。同样的还有64位版本的下载,清参考博客的另一个资源。

2017-12-01

McGrawHill_-_Machine_Learning_-Tom_Mitchell课后答案

McGrawHill Machine Learning Tom_Mitchell 课后完整版答案

2016-04-25

最快搜索kd树

一种最快的搜索kds树的实现,时间搜索的效率更高

2014-12-25

线段树的一种实现

一种简单的线段树的实现 ,基础功能比较完善

2014-12-25

全面的kd搜索树

一种功能实现全面的kd搜索树,简单灵活,容易使用

2014-12-25

空空如也

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

TA关注的人

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