科学网

 找回密码
  注册
科学网 标签 windows 相关日志

tag 标签: windows

相关日志

[转载]在windows下编写tail命令,提供源码和exe下载
dubo 2013-4-17 15:53
tail_windows.exe 本程序编写于32/64位win7旗舰版,测试也是在这个系统下,欢迎朋友们提出修改意见。 功能: 显示指定文本文件的最后n行,支持自动读取及手动按回车读取。 格式说明: tail fileName 标志说明: -b Number 从末尾倒数 Number 表示的 512 字节块位置开始读取指定文件(无此参数则默认最后512字节),若要读取大量文本请将此值调大,例如:tail -b 10 filename.txt -l Number 显示末尾Number行(无此参数则默认显示最后30行) -f Number 每隔多少秒自动显示(无此参数则手动按回车显示下一次) 下面是调用例子: tail -f 1 -b 2 -l 10 t.txt 每一秒自动显示一次(-f 1),最多从末尾读取512*2个字节(-b 2),从这些字节中读取最后10行(-l 10) tail -b 2 -l 50 t.txt 最多从末尾读取512*2个字节(-b 2),从这些字节中读取最后50行(-l 50),手动按回车显示(省略 ) tail -b 2 t.txt 最多从末尾读取512*2个字节(-b 2),从这些字节中读取最后30行(省略 默认读取最后30行),手动按回车显示(省略 ) Cpp代码 #include windows.h #include iostream #include fstream #include string #include malloc.h #include stdlib.h using namespace std; /** * 格式说明: * tail fileName * * 标志说明: * -b Number * 从末尾倒数 Number 表示的 512 字节块位置开始读取指定文件(无此参数则默认最后512字节) * -l Number * 显示末尾Number行(无此参数则默认显示最后30行) * -f Number * 每隔多少秒自动显示(无此参数则手动按回车显示下一次) * * 例: * tail -f 1 -b 2 -l 10 t.txt * 每一秒自动显示一次(-f 1),最多从末尾读取512*2个字节(-b 2),从这些字节中读取最后10行(-l 10) * * tail -b 2 -l 50 t.txt * 最多从末尾读取512*2个字节(-b 2),从这些字节中读取最后50行(-l 50),手动按回车显示(省略 ) * * tail -b 2 t.txt * 最多从末尾读取512*2个字节(-b 2),从这些字节中读取最后30行(省略 默认读取最后30行),手动按回车显示(省略 ) */ // 检查字符数组的内容是否是标志 bool isFlag( char * charArr) { string temp = charArr; if (charArr == '-' ) { // 是以减号开头 if (temp!= -b temp!= -f temp!= -l ) { // 非法标志 return false ; } return true ; } else return false ; } // 检查字符数组的内容是否是正整数,不是正整数则返回零 int isNum( char * charArr) { try { int v = atoi(charArr); // 将当前参数转整数 if ( atoi(charArr) 1 ) return 0; return v; } catch (...) { return 0; } } /** * 检查参数是否正确 * @param argc 一共有几个参数(从1开始) * @param arg 用户输入的参数 * * @return int (1:验证通过|-1:验证失败) */ int checkArg( int argc, char ** arg, int * b, int * l, int * f, char ** filename) { // 返回值 int ret = 1; // 前一个参数是否是标志 bool preArgIsFlag = false ; // 是否已经读到文件名 bool readedFileName = false ; // 是否已经读到-b bool readedB = false ; // 是否已经读到-l bool readedL = false ; // 是否已经读到-f bool readedF = false ; // 一维数组下标 int x = 0, v = 0; string temp, temp1, temp2; // 按元素个数从1开始循环 for ( int i=1; iargc; i++) { temp1 = arg ; if (i argc-1) { temp2 = arg ; } // 检查当前循环到的是不是最后一个元素 if (i argc-1) // 如果当前循环到的不是最后一个元素 { if (isFlag(arg )) // 如果当前元素是标志 { if (!isFlag(arg )) // 如果下一个元素不是标志 { // 如果当前元素是标志、下一个元素不是标志 v = isNum(arg ); if (v 1) return 0; if (temp1 == -b ) { if (readedB) // 如果已经读到-b则返加零 return 0; *b = v; readedB = true ; } else if (temp1 == -l ) { if (readedL) // 如果已经读到-l则返加零 return 0; *l = v; readedL = true ; } else if (temp1 == -f ) { if (readedF) // 如果已经读到-f则返加零 return 0; *f = v; readedF = true ; } else { // 非法标志 return 0; } i++; } else // 如果下一个元素是标志 { return 0; } } else { // 如果当前元素不是标志则认定当前元素是文件名 if (readedFileName) // 如果已经读到文件名则返回零 return 0; strcpy(*filename, arg ); // 修改传入参数中的文件名 readedFileName = true ; } } // if(i argc-1) // 如果当前循环到的不是最后一个元素 else // 如果当前循环到的是最后一个元素 { if (isFlag(arg )){ // 如果当前元素是标志 return 0; } else // 如果当前元素不是标志 { if (readedFileName) // 如果已经读到文件名则返回零 return 0; strcpy(*filename, arg ); // 修改传入参数中的文件名 readedFileName = true ; } } } // for(int i=1; iargc; i++) if (!readedB) // 如果没有读到-b则赋默认值 { *b = 1; } if (!readedL) // 如果没有读到-l则赋默认值 { *l = 30; } if (!readedF) // 如果没有读到-f则赋默认值 { *f = 0; } // 判断是否有文件名 if (!readedFileName) return 0; return ret; } int main( int argc, char ** argv) { // int b; // 缓冲区大小(是几个512) int l; // 要末尾读多少行 int f; // 每隔几秒自动显示 char * filename = new char ; // 检查参数是否正确 int result = checkArg(argc, argv, b, l, f, filename); if (!result) { printf( 出现错误,请参照以下说明修改命令参数:\n ); printf( 格式说明:\n ); printf( tail fileName \n ); printf( 其中fileName最长512字节\n\n ); printf( 标志说明:\n ); printf( -b Number\n ); printf( 从末尾倒数 Number 表示的 512 字节块位置开始读取指定文件(无此参数则默认最后512字节)\n ); printf( -l Number\n ); printf( 显示末尾Number行(无此参数则默认显示最后30行)\n ); printf( -f Number\n ); printf( 每隔多少秒自动显示(无此参数则手动按回车显示下一次)\n\n ); printf( 例:\n ); printf( tail -f 1 -b 2 -l 10 t.txt \n ); printf( 每一秒自动显示一次(-f 1),最多从末尾读取512*2个字节(-b 2),从这些字节中读取最后10行(-l 10)\n\n ); printf( tail -b 2 -l 50 t.txt\n ); printf( 最多从末尾读取512*2个字节(-b 2),从这些字节中读取最后50行(-l 50),手动按回车显示(省略 )\n\n ); printf( tail -b 2 t.txt\n ); printf( 最多从末尾读取512*2个字节(-b 2),从这些字节中读取最后30行(省略 默认读取最后30行),手动按回车显示(省略 )\n ); return 1; } // 要显示多少行 int showCount = l, showLineCount; // 文件总大小 int count; char * charArr; while ( true ) { showLineCount = showCount; ifstream ifs; // 按二进制读取文本 ifs.open (filename, ios::binary); if (ifs.fail()) { cout 错误:文件不存在。 endl; return 1; } // 将文件指针移动到末尾 ifs.seekg (0, ios::end); // 读取文件总大小 count = ifs.tellg(); // 根据文件总大小计算应该读取多少字节 int shouldReadLength = (count=512*b)?512*b:count; // 按指定大小分配内存,加1是为了能在最后添加结束符'\0' charArr = new char ; int i; // 已读取字节数 int readed = 0; // 将文件指针移动到距末尾-shouldReadLength个字节的位置 ifs.seekg (-shouldReadLength, ios::end); // 读取指定大小的内容 ifs.read (charArr,shouldReadLength); // 添加结束符 charArr = '\0' ; for (i=shouldReadLength-1; i=0 showLineCount0; i--,readed++) { if (charArr == '\n' ){ showLineCount--; } } // 输出 printf( %s\n , charArr + shouldReadLength - readed); // 这种方法可以输出到控制台 //cout.write (charArr + shouldReadLength - readed,readed);// 这种方法也可以输出到控制台 // 释放字符数组的内存空间 delete [] charArr; // 关闭文件流 ifs.close(); if (f==0) // 用户没有输入-f参数,等待用户再次敲回车 { // 如果用手动的就用cin---------- 开始 cout 按Ctrl+C退出或按回车继续: ; // 用户按回车时进行下一次显示 cin.get(); //system(PAUSE); // 如果用手动的就用cin---------- 结束 } else // 用户输入了-f参数,按用户输入的秒数睡眠 { // 如果要自动的就用Sleep-------- 开始 Sleep(1000*f); // 如果要自动的就用Sleep-------- 结束 } } return 0; } 转载:http://stride.iteye.com/blog/1144745
个人分类: C语言|3445 次阅读|0 个评论
Linux & Unix & Windows 操作系统学习心得
businessman 2013-3-19 21:27
2013 年 3 月 19 日 ________________________________________________________________________________________ 题记:好记心不如烂笔头!阅读时往往会有所悟,而这种感悟则通常比书籍本身的内容更有价值,因为这是你阅读时的思考,代表了你对于相关知识的个人领悟。以文字形式记录下来,方便以后参考。
个人分类: 学习手记|156 次阅读|0 个评论
使用多核CPU,并行编程超简单。(OpenMP的Windows & Linux 例子)
热度 1 bigdataage 2013-3-19 16:43
使用多核CPU,并行编程超简单! OpenMP提供了对 并行算法 的高层的抽象描述, 程序员 通过在 源代码 中加入专用的pragma来指明自己的意图,由此 编译器 可以自动将程序进行并行化,并在必要之处加入同步互斥以及通信。但是,作为高层抽象,OpenMP并不适合需要复杂的线程间同步和互斥的场合。OpenMP的另一个缺点是不能在非 共享内存 系统(如 计算机集群 )上使用,在这样的系统上,MPI使用较多。 当然,还有一个更简单的方法就是使用Go语言。 Windows 例子( Visual Studio,C语言) 我用的是 Windows系统(Win8)的双核台式机 , 用 C语言写源代码, 以Visual Studio 2012为编译器。打开 Visual Studio 2012, 需要在建立工程后,点击 菜单栏-Project-Properties,弹出菜单里,点击 Configuration Properties-C/C++-Language-OpenMP Support,在下拉菜单里选择Yes。然后才能使用OpenMP。 下面以并行代码为例,只需要把相应的行注释掉,就是串行代码了!下同。 第一个例子(example_1.c): 增加一行代码#pragma omp parallel,然后用花括号把你需要放在并行区内的语句括起来,并行区就创建好了。 默认情况下,并行区内线程数=系统中核的个数。 并行区里每个线程都会去执行并行区中的代码。故对于双核电脑, 并行区中的代码会被执行2次,当然若有输出语句,结果也会被输出2次 。 运行example_1.c, 会发现 并行区里面的语句会被执行2次(我的电脑是2核的 ), 多次运行,会发现各次运行的结果会不一样,打印到屏幕上结果的顺序是不一定的,这个符合多线程程序的特性。 当然, 运行过程中也可以观察到CPU的使用率是100%. 我运行了2次,结果不同,如下所示: 第二个例子(example_2.c): example_1.c中并行区里每个线程执行的代码是一样的,计算机若有N个核,相当于同时重复执行了N次,并没有提高效率、节省时间。我们希望的是把同一工作分配给不同线程来做,每个线程完成一部分,这样运行速率才会快。 #pragma omp for 使用这个语句,就可以把一个for循环的工作量分配给不同线程。这个语句后面必须紧跟一个for循环,它只能对循环的工作量进行划分、分配。 可以把多行openmp pragma合并成一行, #pragma omp parallel, #pragma omp for 合并成一行#pragma omp parallel for , 合并后的程序如下: 并行计算的运行用了16.415秒。 把第11行(#pragma omp parallel for)注释以后, 就成为了传统的串行计算,运行用了29.116秒。 双核运行的时间大约缩短为单核的二分之一,说明OpenMP还是很强大的。运行过程中也可以观察到CPU的使用率是100%. Linux 例子(GCC,C语言) 源代码和Windows 中的 差不多,用 GCC 编译时加上 -fopenmp 就可以了. 未完待续。 2013年6月1号 以后继续纠结这个问题。没办法,又要写英文的期刊论文,又要写硕士毕业论文。 参考: http://www.openmp.org http://baike.baidu.com/view/1687659.htm http://www.cnblogs.com/yangyangcv/archive/2012/03/23/2413335.html http://linux.chinaunix.net/techdoc/develop/2006/10/19/942441.shtml http://www.rosoo.net/a/201111/15347.html http://hi.baidu.com/diwulechao/item/bc6d865c411b813c32e0a932 http://baike.baidu.com/view/3674653.htm http://baike.baidu.com/view/1516611.htm Go语言相关网站: http://code.google.com/p/go/ http://go-lang.cat-v.org/ http://code.google.com/p/golang-china/ http://zh.golanger.com/ http://tieba.baidu.com/f?kw=go%D3%EF%D1%D4fr=ala0 http://studygolang.com/
26378 次阅读|1 个评论
[转载]打印机共享
grapeson 2013-3-9 19:45
Windows XP【打印机】打印机共享设置 一、确认局域网内部计算机名称不冲突?如有相同之名称?请改之??并建立统一的“工作组”名。右击“我的电脑”?单击“属性”?点击“计算机名”选项卡?点击“更改”?重点是?计算机名称不能相同?工作组名称要一致?。 二、确认局域网内各电脑已安装“Microsoft 网络的文件和打印机共享”协议?正常情况都默认安装了。右击“网上邻居”?单击“属性”?右击“本地连接”? 单击“属性”? 在“常规”选项卡中单击“安装”?选择“协议”?点击“添加”?选择"NWLINK IPX/SPX/NET........."?单击“确定”。 三、主机设置局域网共享 1、点击“设置家庭或小型办公网络”?在“网络安装向导”中两次单击“下一步”? 2、在“选择连接方法”—“选择最能恰当描述这台计算机的说明”中?选中 “此计算机通过居民区的网关或网络上的其他计算机连接INTERNET” ?单击“下一步”? 3、在“给这台计算机提供描述和名称”中 ?单击“下一步”? 4、在“命名您的网络”中填写“工作组名” ?单击“下一步”? 5、在“文件和打印机共享”中 ?选中 “启用文件和打印机共享”?单击“下一步”? 6、在“准备应用网络设置”中单击“下一步”? 7、在“快完成了”中选择“完成该向导。我不需要在其他计算机上运行该向导。”?单击“下一步”? 8、在“正在完成网络安装向导”中单击“完成”。 四、关闭主机防火墙?控制面板里?点击“更改windows防火墙设置”?选择“关闭”。点击“确定”。 五、主机设置共享打印机。 1、右击打印机图标?点击“属性”?点击“共享”选项?在“共享”选项卡中选择“共享这台打印机”?单击“应用”、“确定”? 打印机图标比之前多出一个“小手”。 2、右击打印机图标?点击“属性”? 点击“打印测试页”?以检验打印机安装是否正确。 六、主机管理工具设置 1、计算机管理-点击“本地用户和组”?双击“用户”?来宾帐户“Guest”设为启用。 2、本地安全策略-①用户权利指派-“从网络访问此计算机”项添加“Guest”?“拒绝从网络访问这台计算机”项删除“Guest”。②安全选项-“网络访问?本地帐户的共享和安全模式”项设为“仅来宾-本地用户以来宾身份验证”?正常情况省略该步?。 七、在客户电脑中添加打印机。 1、安装同版本的打印机驱动? 2、添加打印机。依次点击“开始”、“打印机和传真”、“添加打印机”、下一步、选择“网络打印机或连接到其他计算机的打印机”、下一步、选择“浏览打印机”、选择并单击主机电脑、选中打印机、下一步、点击“是”、点击“确定”、点击“完成”?右击打印机图标?点击“属性”? 点击“打印测试页”?以检验打印机共享设置是否正确。
1786 次阅读|0 个评论
Windows server 2003 64位+ArcGIS10系列+Oracle11 64
gisbase 2013-3-9 16:51
Windows server 2003 64位+ArcGIS10系列+Oracle11 64 终于把desktop、engine、sde、server全部安装好了。 公路系统更新完毕,开始新的征程! 这个过程太不容易了,esri再努力下,尽可能把产品变的更小、更好安装吧!!! 其中也遇到许多问题,主要如下: 1 oracle 使用database control 配置数据库时,要求在当前oracle主目录中配置监听程序,必须运行Netca以配置 http://210.43.24.222/chy/3sbase/news/?1009.html 2 通过ArcCatalog SDE可以创建矢量,而栅格均不行,解决方法 http://210.43.24.222/chy/3sbase/news/?1016.html 3 ArcCatalog配置GIS Servers错误access denied :either the som service on machine... . http://210.43.24.222/chy/3sbase/news/?1015.html
3981 次阅读|0 个评论
[转载]DPM程序在windows下调试步骤:运行demo
hailuo0112 2013-2-25 10:07
由于该程序是在linux或者Apple系统的,所以需要改一些地方使demo.m能够在windows下运行 需要改动的地方: 1、把用到的文件dt.cc resize.cc fconv.cc features.cc、getdetection.cc的后缀都修改为cpp 2、dt.cpp中加:#define int32_t int 3、features.cpp、resize.cpp、fconv.cpp中加入 view plaincopy #define bzero(a, b) memset(a, 0, b) int round(float a) { float tmp = a - (int)a; if( tmp = 0.5 ) return (int)a + 1; else return (int)a; } 4、resize.cpp中的alphainfo ofs 换成:alphainfo *ofs = new alphainfo 当然要记得释放 这个内存,但要注意放得位置。 5、注释掉compile 中mex -O fconvsse.cc -o fconv这句,因为该程序用到其他平台的多线程,在windows 之下无法使用,然后在comopile最后一行加入 mex -O fconv.cc; 之后就可以在matlab中运行compile进行编译了,这时会出现一些重定义的错误,应该是vc6.0对c++的一些 不兼容,修改下就可以了。x重定义的--z,o重定义的--oo; 6、输入demo()。查看结果。
个人分类: DPM|3891 次阅读|0 个评论
[转载]linux的mount命令详解
fangxia 2013-2-22 16:55
转自http://blog.csdn.net/leo201592/article/det linux下挂载(mount)光盘映像文档、移动硬盘、U盘、Windows和NFS网络共享 linux是个优秀的开放源码的操作系统,能够运行在大到巨型小到掌上型各类电脑系统上,随着linux系统的日渐成熟和稳定连同他开放源代码特有的优越性,linux在全世界得到了越来越广泛的应用。现在许多企业的电脑系统都是由UNIX系统、Linux系统和Windows系统组成的混合系统,不同系统之间经常需要进行数据交换。下面我根据自己的实际工作经验介绍一下如何在linux系统下挂接(mount)光盘映像文档、移动硬盘、U盘连同Windows网络共享和UNIX NFS网络共享。    挂接命令 (mount)   首先,介绍一下挂接(mount)命令的使用方法,mount命令参数很多,这里主要讲一下今天我们要用到的。   命令格式:   mount device dir   其中:   1.-t vfstype 指定文档系统的类型,通常不必指定。mount 会自动选择正确的类型。常用类型有:   光盘或光盘映像:iso9660   DOS fat16文档系统:msdos   Windows 9x fat32文档系统:vfat   Windows NT ntfs文档系统:ntfs   Mount Windows文档网络共享:smbfs   UNIX(LINUX) 文档网络共享:nfs linux 的硬盘分区: ext3 或ext4   2.-o options 主要用来描述设备或档案的挂接方式。常用的参数有:   loop:用来把一个文档当成硬盘分区挂接上系统   ro:采用只读方式挂接设备   rw:采用读写方式挂接设备   iocharset:指定访问文档系统所用字符集   3.device 要挂接(mount)的设备。   4.dir设备在系统上的挂接点(mount point)。    挂接光盘映像文档   由于近年来磁盘技术的巨大进步,新的电脑系统都配备了大容量的磁盘系统,在Windows下许多人都习惯把软件和资料做成光盘映像文档通过虚拟光驱来使用。这样做有许多好处:一、减轻了光驱的磨损;二、现在硬盘容量巨大存放几十个光盘映像文档不成问题,随用随调十分方便;三、硬盘的读取速度要远远高于光盘的读取速度,CPU占用率大大降低。其实linux系统下制作和使用光盘映像比Windows系统更方便,不必借用任何第三方软件包。   1、从光盘制作光盘映像文档。将光盘放入光驱,执行下面的命令。    #cp /dev/cdrom /home/sunky/mydisk.iso 或    #dd if=/dev/cdrom of=/home/sunky/mydisk.iso    注:执行上面的任何一条命令都可将当前光驱里的光盘制作成光盘映像文档/home/sunky/mydisk.iso   2、将文档和目录制作成光盘映像文档,执行下面的命令。    #mkisofs -r -J -V mydisk -o /home/sunky/mydisk.iso /home/sunky/ mydir    注:这条命令将/home/sunky/mydir目录下任何的目录和文档制作成光盘映像文档/home/sunky/mydisk.iso,光盘卷标为:mydisk   3、光盘映像文档的挂接(mount)    #mkdir /mnt/vcdrom    注:建立一个目录用来作挂接点(mount point)    #mount -o loop -t iso9660 /home/sunky/mydisk.iso /mnt/vcdrom    注:使用/mnt/vcdrom就能够访问盘映像文档mydisk.iso里的任何文档了。        挂接移动硬盘   对linux系统而言,USB接口的移动硬盘是当作SCSI设备对待的。插入移动硬盘之前,应先用fdisk –l 或 more /proc/partitions查看系统的硬盘和硬盘分区情况。    # fdisk -l   Disk /dev/sda: 73 dot 4 GB, 73407820800 bytes   255 heads, 63 sectors/track, 8924 cylinders   Units = cylinders of 16065 * 512 = 8225280 bytes   Device Boot Start End Blocks Id System   /dev/sda1 1 4 32098+ de Dell Utility   /dev/sda2 * 5 2554 20482875 7 HPFS/NTFS   /dev/sda3 2555 7904 42973875 83 Linux   /dev/sda4 7905 8924 8193150 f Win95 Ext'd (LBA)   /dev/sda5 7905 8924 8193118+ 82 Linux swap   在这里能够清楚地看到系统有一块SCSI硬盘/dev/sda和他的四个磁盘分区/dev/sda1 -- /dev/sda4,/dev/sda5是分区/dev/sda4的逻辑分区。接好移动硬盘后,再用fdisk –l 或 more/proc/partitions查看系统的硬盘和硬盘分区情况    # fdisk -l   Disk /dev/sda: 73 dot 4 GB, 73407820800 bytes   255 heads, 63 sectors/track, 8924 cylinders   Units = cylinders of 16065 * 512 = 8225280 bytes   Device Boot Start End Blocks Id System   /dev/sda1 1 4 32098+ de Dell Utility   /dev/sda2 * 5 2554 20482875 7 HPFS/NTFS   /dev/sda3 2555 7904 42973875 83 Linux   /dev/sda4 7905 8924 8193150 f Win95 Ext'd (LBA)   /dev/sda5 7905 8924 8193118+ 82 Linux swap   Disk /dev/sdc: 40.0 GB, 40007761920 bytes   255 heads, 63 sectors/track, 4864 cylinders   Units = cylinders of 16065 * 512 = 8225280 bytes   Device Boot Start End Blocks Id System   /dev/sdc1 1 510 4096543+ 7 HPFS/NTFS   /dev/sdc2 511 4864 34973505 f Win95 Ext'd (LBA)   /dev/sdc5 511 4864 34973473+ b Win95 FAT32   大家应该能够发现多了一个SCSI硬盘/dev/sdc和他的两个磁盘分区/dev/sdc1?、/dev/sdc2,其中/dev/sdc5是/dev/sdc2分区的逻辑分区。我们能够使用下面的命令挂接/dev/sdc1和/dev/sdc5。    #mkdir -p /mnt/usbhd1    #mkdir -p /mnt/usbhd2    注:建立目录用来作挂接点(mount point)    #mount -t ntfs /dev/sdc1 /mnt/usbhd1    #mount -t vfat /dev/sdc5 /mnt/usbhd2    注:对ntfs格式的磁盘分区应使用-t ntfs 参数,对fat32格式的磁盘分区应使用-t vfat参数。若汉字文档名显示为乱码或不显示,能够使用下面的命令格式。    #mount -t ntfs -o iocharset=cp936 /dev/sdc1 /mnt/usbhd1    #mount -t vfat -o iocharset=cp936 /dev/sdc5 /mnt/usbhd2   linux系统下使用fdisk分区命令和mkfs文档系统创建命令能够将移动硬盘的分区制作成linux系统所特有的ext2、ext3格式。这样,在linux下使用就更方便了。使用下面的命令直接挂接即可。    #mount /dev/sdc1 /mnt/usbhd1        挂接 U 盘   和USB接口的移动硬盘相同对linux系统而言U盘也是当作SCSI设备对待的。使用方法和移动硬盘完全相同。插入U盘之前,应先用fdisk –l 或 more /proc/partitions查看系统的硬盘和硬盘分区情况。    # fdisk -l   Disk /dev/sda: 73 dot 4 GB, 73407820800 bytes   255 heads, 63 sectors/track, 8924 cylinders   Units = cylinders of 16065 * 512 = 8225280 bytes   Device Boot Start End Blocks Id System   /dev/sda1 1 4 32098+ de Dell Utility   /dev/sda2 * 5 2554 20482875 7 HPFS/NTFS   /dev/sda3 2555 7904 42973875 83 Linux   /dev/sda4 7905 8924 8193150 f Win95 Ext'd (LBA)   /dev/sda5 7905 8924 8193118+ 82 Linux swap   插入U盘后,再用fdisk –l 或 more /proc/partitions查看系统的硬盘和硬盘分区情况。    # fdisk -l   Disk /dev/sda: 73 dot 4 GB, 73407820800 bytes   255 heads, 63 sectors/track, 8924 cylinders   Units = cylinders of 16065 * 512 = 8225280 bytes   Device Boot Start End Blocks Id System   /dev/sda1 1 4 32098+ de Dell Utility   /dev/sda2 * 5 2554 20482875 7 HPFS/NTFS   /dev/sda3 2555 7904 42973875 83 Linux   /dev/sda4 7905 8924 8193150 f Win95 Ext'd (LBA)   /dev/sda5 7905 8924 8193118+ 82 Linux swap   Disk /dev/sdd: 131 MB, 131072000 bytes   9 heads, 32 sectors/track, 888 cylinders   Units = cylinders of 288 * 512 = 147456 bytes   Device Boot Start End Blocks Id System   /dev/sdd1 * 1 889 127983+ b Win95 FAT32   Partition 1 has different physical/logical endings:   phys=(1000, 8, 32) logical=(888, 7, 31)   系统多了一个SCSI硬盘/dev/sdd和一个磁盘分区/dev/sdd1,/dev/sdd1就是我们要挂接的U盘。   #mkdir -p /mnt/usb   注:建立一个目录用来作挂接点(mount point)   #mount -t vfat /dev/sdd1 /mnt/usb   注:现在能够通过/mnt/usb来访问U盘了, 若汉字文档名显示为乱码或不显示,能够使用下面的命令。   #mount -t vfat -o iocharset=cp936 /dev/sdd1 /mnt/usb    挂接 Windows 文档共享   Windows网络共享的核心是SMB/CIFS,在linux下要挂接(mount)windows的磁盘共享,就必须安装和使用samba软件包。现在流行的linux发行版绝大多数已包含了samba软件包,假如安装linux系统时未安装samba请首先安装samba。当然也能够到www.samba.org网站下载......新的版本是3.0.10版。   当windows系统共享配置好以后,就能够在linux客户端挂接(mount)了,具体操作如下:   # mkdir –p /mnt/samba   注:建立一个目录用来作挂接点(mount point)   # mount -t smbfs -o username=administrator,password=pldy123 //10.140.133.23/c$ /mnt/samba   注:administrator 和 pldy123 是ip地址为10.140.133.23 windows电脑的一个用户名和密码,c$是这台电脑的一个磁盘共享   如此就能够在linux系统上通过/mnt/samba来访问windows系统磁盘上的文档了。以上操作在redhat as server3、redflag server 4.1、suse server 9连同windows NT 4.0、windows 2000、windowsxp、windows 2003环境下测试通过。    挂接 UNIX 系统 NFS 文档共享   类似于windows的网络共享,UNIX(Linux)系统也有自己的网络共享,那就是NFS(网络文档系统),下面我们就以SUN Solaris2.8和REDHAT as server 3 为例简单介绍一下在linux下如何mount nfs网络共享。   在linux客户端挂接(mount)NFS磁盘共享之前,必须先配置好NFS服务端。   1、Solaris系统NFS服务端配置方法如下:    (1)修改 /etc/dfs/dfstab, 增加共享目录       share -F nfs -o rw /export/home/sunky    (2)启动nfs服务       # /etc/init.d/nfs.server start    (3)NFS服务启动以后,也能够使用下面的命令增加新的共享       # share /export/home/sunky1       # share /export/home/sunky2    注:/export/home/sunky和/export/home/sunky1是准备共享的目录   2、linux系统NFS服务端配置方法如下:    (1)修改 /etc/exports,增加共享目录   /export/home/sunky 10.140.133.23(rw)   /export/home/sunky1 *(rw)   /export/home/sunky2 linux-client(rw)    注:/export/home/目录下的sunky、sunky1、sunky2是准备共享的目录,10.140.133.23、*、linux-client是被允许挂接此共享linux客户机的IP地址或主机名。假如要使用主机名linux-client必须在服务端主机/etc/hosts文档里增加linux-client主机ip定义。格式如下:    10.140.133.23 linux-client    (2)启动和停止NFS服务    /etc/rc.d/init.d/portmap start (在REDHAT中PORTMAP是默认启动的)    /etc/rc.d/init.d/nfs start 启动NFS服务    /etc/rc.d/init.d/nfs stop 停止NFS服务    注:若修改/etc/export文档增加新的共享,应先停止NFS服务,再启动NFS服务方能使新增加的共享起作用。使用命令exportfs -rv也能够达到同样的效果。   3、linux客户端挂接(mount)其他linux系统或UNIX系统的NFS共享    # mkdir –p /mnt/nfs    注:建立一个目录用来作挂接点(mount point)    #mount -t nfs -o rw 10.140.133.9:/export/home/sunky /mnt/nfs    注:这里我们假设10.140.133.9是NFS服务端的主机IP地址,当然这里也能够使用主机名,但必须在本机/etc/hosts文档里增加服务端ip定义。/export/home/sunky为服务端共享的目录。   如此就能够在linux客户端通过/mnt/nfs来访问其他linux系统或UNIX系统以NFS方式共享出来的文档了。以上操作在redhat as server 3、redflag server4.1、suse server 9连同Solaris 7、Solaris8、Solaris 9 for x86sparc环境下测试通过。 权限问题: 假設 server 端的使用者 jack, user id 為 1818, gid 為 1818, client 端也有一個使用者jack,但是 uid 及 gid 是 1818。client 端的 jack 希望能完全讀寫 server 端的 /home/jack這個目錄。server 端的 /etc/exports 是 這樣寫的: /home/jack *(rw,all_squash,anonuid=1818,anongid=1818) 這個的設定檔的意思是,任何 client 端的使用者存取 server 端 /home/jack 這 目錄時,都會 map 成 server 端的 jack (uid,gid=1818)。我 mount 的結果是 1. client 端的 root 能够完全存取該目錄, 包括讀、寫、殺……等 2. client 端的 jack (uid,gid=1818) 我能够做: rm -rf server_jack/* cp something server_jack/ mkdir server_jack/a
3200 次阅读|0 个评论
[转载]windows下DPM经验2
hailuo0112 2013-2-19 14:43
接着昨天的继续 昨天吧demo()跑通了,今天我们继续修改训练部分。 同样参看了pozen同学的博客。 1、首先下载voc的数据库和相应的VOCdevkit。(注意吧数据也放在VOCdevkit的目录中) 2、修改global.m文件中的文件路径(根据自己需求和自己缩放位置修改) 3、根据pozen同学的说明修改了一些文件,还有unix换成了system的命令,一些命令换成windows下的命令(参考前一篇文章)。 说下我自己遇到的问题: 4、procid.m文件中的“/”修改为“\"。因为window下目录与linux下的差异。 5、还有就是learn.cpp的编译了。 遇到的问题有: 1、srand48 和drand48 在windows下没有,根据原理自己编了一个。不对请指出: view plain copy #defineMNWZ0x100000000 #defineANWZ0x5DEECE66D #defineCNWZ0xB16 #defineINFINITY0xFFFFFFFFF intlabelsize; intdim; staticunsignedlonglong seed = 1 ; doubledrand48(void) { seed =(ANWZ*seed+CNWZ)0xFFFFFFFFFFFFLL; unsignedint x = seed 16; return((double)x/(double)MNWZ); } //staticunsignedlonglong seed = 1 ; voidsrand48(unsignedinti) { seed =(((longlongint)i) 16 )|rand(); } 2、INFINITY(linux下无穷大的标记),在windows下没有这个标志,因为是double型的数据 于是我定义了:#define INFINITY 0xFFFFFFFFF(不知道对不对,运行没错误)。 3、 view plain copy string filepath = string (logdir)+"/learnlog/"+string(logtag)+".log"; 一直报错,最后我吧#include string.h改成了#include string就没问题了。应该说搜索路径的问题。 之后就可以运行了。如果不确定,大家可以先运行matlab,生成需要的一些文件,然后通过输入命令行去单步调试learn.cpp文件。 源代码中:readme中描述: 1.Downloadandinstallthe2006/2007/2008PASCALVOCdevkitanddataset. (youshouldsetVOCopts.testset='test'inVOCinit.m) 2.Modify'globals.m'accordingtoyourconfiguration. 3.Run'make'tocompilelearn.cc,theLSVMgradientdescentcode. (Runfromashell,notMatlab.) 4.Startmatlab. 5.Runthe'compile'scripttocompilethehelperfunctions. (youmayneedtoeditcompile.mtouseadifferentconvolution routinedependingonyoursystem) 6.Usethe'pascal'scripttotrainandevaluateamodel. example: pascal('person',3);%trainandevaluatea6componentpersonmodel 这里贴出learn.cpp最后成功运行的代码: view plain copy #include stdio.h #include stdlib.h #include string #include math.h #include time.h #include errno.h #include fstream #include iostream //#include"stdafx.h" usingnamespacestd; /* *OptimizeLSVMobjectivefunctionviagradientdescent. * *Weuseanadaptivecachemechanism.Afteranegativeexample *scoresbeyondthemarginmultipletimesitisremovedfromthe *trainingsetforafixednumberofiterations. */ //DataFileFormat //EXAMPLE* // //EXAMPLE: //longlabelints //blocksint //dimint //DATA{blocks} // //DATA: //blocklabelfloat //blockdatafloats // //InternalBinaryFormat //lenint(bytelengthofEXAMPLE) //EXAMPLE see above //uniqueflagbyte //numberofiterations /*#ifndefDRAND48_H #defineDRAND48_H #include stdlib.h */ //#definem0x100000000LL //#definea0x5DEECE66DLL //staticunsignedlonglong seed = 1 ; //#endif //#defineInfinity1.0+308 #defineITER10e6 //minimum#ofiterationsbeforetermination #defineMIN_ITER5e6 //convergencethreshold #defineDELTA_STOP0.9995 //numberoftimesinarowtheconvergencethreshold //mustbereachedbeforestopping #defineSTOP_COUNT5 //smallcacheparameters #defineINCACHE25 #defineMINWAIT(INCACHE+25) #defineREGFREQ20 //errorchecking #definecheck(e)\ (e?(void)0:(printf("%s:%uerror:%s\n%s\n",__FILE__,__LINE__,#e,strerror(errno)),exit(1))) //numberofnon-zeroblocksinexampleex #defineNUM_NONZERO(ex)(((int*)ex) ) //floatpointertodatasegmentofexampleex #defineEX_DATA(ex)((float*)(ex+sizeof(int)*(labelsize+3))) //classlabel(+1or-1)fortheexample #defineLABEL(ex)(((int*)ex) ) //blocklabel(convertedto0-basedindex) #defineBLOCK_IDX(data)(((int)data )-1) //setto0tousemax-componentL2regularization //setto1tousefullmodelL2regularization #defineFULL_L20 #defineMNWZ0x100000000 #defineANWZ0x5DEECE66D #defineCNWZ0xB16 #defineINFINITY0xFFFFFFFFF intlabelsize; intdim; staticunsignedlonglong seed = 1 ; doubledrand48(void) { seed =(ANWZ*seed+CNWZ)0xFFFFFFFFFFFFLL; unsignedint x = seed 16; return((double)x/(double)MNWZ); } //staticunsignedlonglong seed = 1 ; voidsrand48(unsignedinti) { seed =(((longlongint)i) 16 )|rand(); } //comparisonfunctionforsortingexamples intcomp(constvoid*a,constvoid*b){ //sortbyextendedlabelfirst,andwholeexamplesecond... int c = memcmp (*((char**)a)+sizeof(int), *((char**)b)+sizeof(int), labelsize*sizeof(int)); if(c) returnc; //labelsarethesame int alen =**((int**)a); int blen =**((int**)b); if( alen ==blen) returnmemcmp(*((char**)a)+sizeof(int), *((char**)b)+sizeof(int), alen); return((alen blen )?-1:1); } //acollapsedexampleisasequenceofexamples structcollapsed{ char**seq; intnum; }; //thetwonodetypesinanAND/ORtree enumnode_type{OR,AND}; //setofcollapsedexamples structdata{ collapsed*x; intnum; intnumblocks; intnumcomponents; int*blocksizes; int*componentsizes; int**componentblocks; float*regmult; float*learnmult; }; //seedtherandomnumbergeneratorwithanarbitrary(fixed)value voidseed_rand(){ srand48(3); //srand(3); } staticinlinedoublemin(doublex,doubley){return(x =y?x:y);} staticinlinedoublemax(doublex,doubley){return(x =y?y:x);} //computethescoreofanexample staticinlinedoubleex_score(constchar*ex,dataX,double**w){ double val = 0 .0; float* data = EX_DATA (ex); int blocks = NUM_NONZERO (ex); for(int j = 0 ;j blocks ;j++){ int b = BLOCK_IDX (data); data++; double blockval = 0 ; for(int k = 0 ;k X.blocksizes ;k++) blockval+=w *data ; data+=X.blocksizes ; val+=blockval; } returnval; } //returnthevalueoftheobjectfunction. //out :lossonnegativeexamples //out :lossonpositiveexamples //out :regularizationterm'svalue doublecompute_loss(doubleout ,doubleC,doubleJ,dataX,double**w){ double loss = 0 .0; #ifFULL_L2 //compute||w||^2 for(int j = 0 ;j X.numblocks ;j++){ for(int k = 0 ;k X.blocksizes ;k++){ loss+=w *w *X.regmult ; } } #else //computemaxnorm^2component for(int c = 0 ;c X.numcomponents ;c++){ double val = 0 ; for(int i = 0 ;i X.componentsizes ;i++){ int b = X .componentblocks ; double blockval = 0 ; for(int k = 0 ;k X.blocksizes ;k++) blockval+=w *w *X.regmult ; val+=blockval; } if(val loss) loss = val ; } #endif loss*=0.5; //recordtheregularizationterm out =loss; //computelossfromthetrainingdata for(int l = 0 ;l =1;l++){ //whichlabelsubsettolookat:-1or1 int subset =(l*2)-1; double subsetloss = 0 .0; for(int i = 0 ;i X.num ;i++){ collapsed x = X .x ; //onlyconsiderexamplesinthetargetsubset char* ptr = x .seq ; if(LABEL(ptr)!=subset) continue; //computemaxoverlatentplacements int M =-1; double V =-INFINITY; //double V =-NWZ; for(int m = 0 ;m x.num ;m++){ double val = ex_score (x.seq ,X,w); if(val V){ M = m ; V = val ; } } //computelossonmax ptr = x .seq ; int label = LABEL (ptr); double mult = C *( label ==1?J:1); subsetloss+=mult*max(0.0,1.0-label*V); } loss+=subsetloss; out =subsetloss; } returnloss; } //gradientdescent voidgd(doubleC,doubleJ,dataX,double**w,double**lb,char*logdir,char*logtag){ ofstreamlogfile; string filepath = string (logdir)+"/learnlog/"+string(logtag)+".log"; /*char*filepath; strcat(filepath,logdir); strcat(filepath,"/learnlog/"); strcat(filepath,logtag); strcat(filepath,"/log");*/ logfile.open(filepath.c_str()); //logfile.open(filepath); logfile.precision(14); logfile.setf(ios::fixed,ios::floatfield); int num = X .num; //stateforrandompermutations int* perm =(int*)malloc(sizeof(int)*X.num); check(perm!=NULL); //stateforsmallcache int* W =(int*)malloc(sizeof(int)*num); check(W!=NULL); for(int j = 0 ;j num ;j++) W =INCACHE; double prev_loss = 1E9 ; bool converged = false ; int stop_count = 0 ; int t = 0 ; while(t ITER !converged){ //pickrandompermutation for(int i = 0 ;i num ;i++) perm =i; for(int swapi = 0 ;swapi num ;swapi++){ int swapj =(int)(drand48()*(num-swapi))+swapi; //int swapj =(int)(rand()*(num-swapi))+swapi; int tmp = perm ; perm =perm ; perm =tmp; } //countnumberofexamplesinthesmallcache int cnum = 0 ; for(int i = 0 ;i num ;i++) if(W =INCACHE) cnum++; int numupdated = 0 ; for(int swapi = 0 ;swapi num ;swapi++){ //selectexample int i = perm ; //skipifexampleisnotinsmallcache if(W INCACHE){ W --; continue; } collapsed x = X .x ; //learningrate double T = min (ITER/2.0,t+10000.0); double rateX = cnum *C/T; t++; if(t% 100000 ==0){ doubleinfo ; double loss = compute_loss (info,C,J,X,w); double delta = 1 .0-(fabs(prev_loss-loss)/loss); logfile t "\t" loss "\t" delta endl ; if(delta =DELTA_STOPt =MIN_ITER){ stop_count++; if(stop_count STOP_COUNT) converged = true ; }elseif(stop_count 0){ stop_count = 0 ; } prev_loss = loss ; printf("\r%7.2f%%ofmax#iterations" "( delta =%.5f;stop count =%d)", 100*double(t)/double(ITER),max(delta,0.0), STOP_COUNT-stop_count+1); fflush(stdout); if(converged) break; } //computemaxoverlatentplacements int M =-1; double V =-INFINITY; //double V =-NWZ; for(int m = 0 ;m x.num ;m++){ double val = ex_score (x.seq ,X,w); if(val V){ M = m ; V = val ; } } char* ptr = x .seq ; int label = LABEL (ptr); if(label*V 1.0 ){ numupdated++; W =0; float* data = EX_DATA (ptr); int blocks = NUM_NONZERO (ptr); for(int j = 0 ;j blocks ;j++){ int b = BLOCK_IDX (data); double mult =(label 0?J:-1)*rateX*X.learnmult ; data++; for(int k = 0 ;k X.blocksizes ;k++) w +=mult*data ; data+=X.blocksizes ; } }else{ if(W ==INCACHE) W =MINWAIT+(int)(drand48()*50); //W =MINWAIT+(int)(rand()*50); else W ++; } //periodicallyregularizethemodel if(t% REGFREQ ==0){ //applylowerbounds for(int j = 0 ;j X.numblocks ;j++) for(int k = 0 ;k X.blocksizes ;k++) w =max(w ,lb ); double rateR = 1 .0/T; #ifFULL_L2 //updatemodel for(int j = 0 ;j X.numblocks ;j++){ double mult = rateR *X.regmult *X.learnmult ; mult = pow ((1-mult),REGFREQ); for(int k = 0 ;k X.blocksizes ;k++){ w =mult*w ; } } #else //assumesimplemixturemodel int maxc = 0 ; double bestval = 0 ; for(int c = 0 ;c X.numcomponents ;c++){ double val = 0 ; for(int i = 0 ;i X.componentsizes ;i++){ int b = X .componentblocks ; double blockval = 0 ; for(int k = 0 ;k X.blocksizes ;k++) blockval+=w *w *X.regmult ; val+=blockval; } if(val bestval){ maxc = c ; bestval = val ; } } for(int i = 0 ;i X.componentsizes ;i++){ int b = X .componentblocks ; double mult = rateR *X.regmult *X.learnmult ; mult = pow ((1-mult),REGFREQ); for(int k = 0 ;k X.blocksizes ;k++) w =mult*w ; } #endif } } } if(converged) printf("\nTerminationcriteriareachedafter%diterations.\n",t); else printf("\nMaxiterationcountreached.\n",t); free(perm); free(W); logfile.close(); } //scoreexamples double*score(dataX,char**examples,intnum,double**w){ double* s =(double*)malloc(sizeof(double)*num); check(s!=NULL); for(int i = 0 ;i num ;i++) s =ex_score(examples ,X,w); returns; } //mergeexampleswithidenticallabels voidcollapse(data*X,char**examples,intnum){ collapsed* x =(collapsed*)malloc(sizeof(collapsed)*num); check(x!=NULL); int i = 0 ; x .seq = examples ; x .num = 1 ; for(int j = 1 ;j num ;j++){ if(!memcmp(x .seq +sizeof(int),examples +sizeof(int), labelsize*sizeof(int))){ x .num++; }else{ i++; x .seq =(examples ); x .num = 1 ; } } X- x = x ; X- num = i +1; } intmain(intargc,char**argv){ seed_rand(); intcount; dataX; //commandlinearguments check( argc ==12); double C = atof (argv ); double J = atof (argv ); char* hdrfile = argv ; char* datfile = argv ; char* modfile = argv ; char* inffile = argv ; char* lobfile = argv ; char* cmpfile = argv ; char* objfile = argv ; char* logdir = argv ; char* logtag = argv ; //readheaderfile FILE* f = fopen (hdrfile,"rb"); check(f!=NULL); intheader ; count = fread (header,sizeof(int),3,f); check( count ==3); int num = header ; labelsize = header ; X.numblocks = header ; X.blocksizes =(int*)malloc(X.numblocks*sizeof(int)); count = fread (X.blocksizes,sizeof(int),X.numblocks,f); check( count ==X.numblocks); X.regmult =(float*)malloc(sizeof(float)*X.numblocks); check(X.regmult!=NULL); count = fread (X.regmult,sizeof(float),X.numblocks,f); check( count ==X.numblocks); X.learnmult =(float*)malloc(sizeof(float)*X.numblocks); check(X.learnmult!=NULL); count = fread (X.learnmult,sizeof(float),X.numblocks,f); check( count ==X.numblocks); check(num!=0); fclose(f); printf("%dexampleswithlabelsize%dand%dblocks\n", num,labelsize,X.numblocks); printf("blocksize,regularizationmultiplier,learningratemultiplier\n"); dim = 0 ; for(int i = 0 ;i X.numblocks ;i++){ dim+=X.blocksizes ; printf("%d,%.2f,%.2f\n",X.blocksizes ,X.regmult ,X.learnmult ); } //readcomponentinfofile //format:#components{#blocksblk1...blk#blocks}^#components f = fopen (cmpfile,"rb"); count = fread (X.numcomponents,sizeof(int),1,f); check( count ==1); printf("themodelhas%dcomponents\n",X.numcomponents); X.componentblocks =(int**)malloc(X.numcomponents*sizeof(int*)); X.componentsizes =(int*)malloc(X.numcomponents*sizeof(int)); for(int i = 0 ;i X.numcomponents ;i++){ count = fread (X.componentsizes ,sizeof(int),1,f); check( count ==1); printf("component%dhas%dblocks:",i,X.componentsizes ); X.componentblocks =(int*)malloc(X.componentsizes *sizeof(int)); count = fread (X.componentblocks ,sizeof(int),X.componentsizes ,f); check( count ==X.componentsizes ); for(int j = 0 ;j X.componentsizes ;j++) printf("%d",X.componentblocks ); printf("\n"); } fclose(f); //readexamples f = fopen (datfile,"rb"); check(f!=NULL); printf("Readingexamples\n"); char** examples =(char**)malloc(num*sizeof(char*)); check(examples!=NULL); for(int i = 0 ;i num ;i++){ //weuseanextrabyteintheendofeachexampletomarkunique //weuseanextraintatthestartofeachexampletostorethe //example'sbytelength(excludinguniqueflagandthisint) //intbuf ; int* buf = new int ; count = fread (buf,sizeof(int),labelsize+2,f); check( count ==labelsize+2); //bytelengthofanexample'sdatasegment int len = sizeof (int)*(labelsize+2)+sizeof(float)*buf ; //memoryfordata,aninitialinteger,andafinalbyte examples =(char*)malloc(sizeof(int)+len+1); check(examples !=NULL); //setdatasegment'sbytelength ((int*)examples ) =len; //settheuniqueflagtozero examples =0; //copylabeldataintoexample for(int j = 0 ;j labelsize +2;j++) ((int*)examples ) =buf ; //readtherestofthedatasegmentintotheexample count = fread (examples +sizeof(int)*(labelsize+3),1, len-sizeof(int)*(labelsize+2),f); check( count ==len-sizeof(int)*(labelsize+2)); delete ); sorted =1; for(int j = 1 ;j num ;j++){ int alen =*((int*)sorted ); int blen =*((int*)sorted ); if(alen!=blen|| memcmp(sorted +sizeof(int),sorted +sizeof(int),alen)){ i++; sorted =sorted ; sorted =1; } } int num_unique = i +1; printf("%duniqueexamples\n",num_unique); //collapseexamples collapse(X,sorted,num_unique); printf("%dcollapsedexamples\n",X.num); //initialmodel double** w =(double**)malloc(sizeof(double*)*X.numblocks); check(w!=NULL); f = fopen (modfile,"rb"); for(int i = 0 ;i X.numblocks ;i++){ w =(double*)malloc(sizeof(double)*X.blocksizes ); check(w !=NULL); count = fread (w ,sizeof(double),X.blocksizes ,f); check( count ==X.blocksizes ); } fclose(f); //lowerbounds double** lb =(double**)malloc(sizeof(double*)*X.numblocks); check(lb!=NULL); f = fopen (lobfile,"rb"); for(int i = 0 ;i X.numblocks ;i++){ lb =(double*)malloc(sizeof(double)*X.blocksizes ); check(lb !=NULL); count = fread (lb ,sizeof(double),X.blocksizes ,f); check( count ==X.blocksizes ); } fclose(f); //train printf("Training\n"); gd(C,J,X,w,lb,logdir,logtag); printf("done\n"); //savemodel printf("Savingmodel\n"); f = fopen (modfile,"wb"); check(f!=NULL); for(int i = 0 ;i X.numblocks ;i++){ count = fwrite (w ,sizeof(double),X.blocksizes ,f); check( count ==X.blocksizes ); } fclose(f); //scoreexamples printf("Scoring\n"); double* s = score (X,examples,num,w); //Writeinfofile printf("Writinginfofile\n"); f = fopen (inffile,"w"); check(f!=NULL); for(int i = 0 ;i num ;i++){ int len =((int*)examples ) ; //label,score,uniqueflag count = fprintf (f,"%d\t%f\t%d\n",((int*)examples ) ,s , (int)examples ); check(count 0); } fclose(f); //computelossandwriteittoafile doublelossinfo ; compute_loss(lossinfo,C,J,X,w); printf("Writingobjectivefunctioninfofile\n"); f = fopen (objfile,"w"); count = fprintf (f,"%f\t%f\t%f",lossinfo ,lossinfo ,lossinfo ); check(count 0); fclose(f); printf("Freeingmemory\n"); for(int i = 0 ;i X.numblocks ;i++){ free(w ); free(lb ); } free(w); free(lb); free(s); for(int i = 0 ;i num ;i++) free(examples ); free(examples); free(sorted); free(X.x); free(X.blocksizes); free(X.regmult); free(X.learnmult); for(int i = 0 ;i X.numcomponents ;i++) free(X.componentblocks ); free(X.componentblocks); free(X.componentsizes); return0; }
个人分类: DPM|3729 次阅读|0 个评论
[转载]windows下的DPM经验
hailuo0112 2013-2-19 14:41
如何在window下运行Discriminatively Trained Deformable Part Models代码 Discriminatively Trained Deformable Part Models的官网: http://www.cs.brown.edu/~pff/latent/ 目前做目标检测最好的一个算法。 搞不懂为什么外国人老喜欢在linux下编代码,也许是因为版权的问题吧。 装了虚拟机在ubuntu下跑通了程序,但........你懂得(虚拟机能让你机子卡死)。 于是着手移植到windows下。 参考了pozen同学的博客: http://blog.csdn.net/pozen/article/details/7023742 启发很大,下面说说自己的调试过程: 1、把用到的文件dt.cc resize.cc fconv.cc features.cc的后缀都修改为cpp 2、dt.cpp中加:#define int32_t int 3、features.cpp、resize.cpp、fconv.cpp中加入 view plain copy #definebzero(a,b)memset(a,0,b) intround(floata){float tmp = a -(int)a;if(tmp =0.5)return(int)a+1;elsereturn(int)a;} 4、resize.cpp中的alphainfo ofs 换成:alphainfo *ofs = new alphainfo 当然要记得释放这个内存,但要注意放得位置。 之后就可以在matlab中运行compile进行编译了,这时会出现一些重定义的错误,应该是vc6.0对c++的一些不兼容,修改下就可以了。 5、输入demo()。查看结果。 调试过程中如何调试c程序参见前一篇文章。 说下自己的编译环境:vs2008matlab2008b 贴出resize.cpp源代码(调试中因为内存错误折腾了很久) view plain copy #include math.h #include assert.h #include string.h #include"mex.h" #definebzero(a,b)memset(a,0,b) intround(floata){float tmp = a -(int)a;if(tmp =0.5)return(int)a+1;elsereturn(int)a;} //structusedforcachinginterpolationvalues structalphainfo{ intsi,di; doublealpha; }; //copysrcintodstusinginterpolationvalues voidalphacopy(double*src,double*dst,structalphainfo*ofs,intn){ structalphainfo* end = ofs +n; while(ofs!=end){ dst +=ofs- alpha*src ; ofs++; } } //resizealongeachcolumn //resultistransposed,sowecanapplyittwiceforacompleteresize voidresize1dtran(double*src,intsheight,double*dst,intdheight, intwidth,intchan){ double scale =(double)dheight/(double)sheight; double invscale =(double)sheight/(double)dheight; //wecachetheinterpolationvaluessincetheycanbe //sharedamongdifferentcolumns int len =(int)ceil(dheight*invscale)+2*dheight; //alphainfoofs ; alphainfo* ofs = new alphainfo ; int k = 0 ; for(int dy = 0 ;dy dheight ;dy++){ double fsy1 = dy *invscale; double fsy2 = fsy1 +invscale; int sy1 =(int)ceil(fsy1); int sy2 =(int)floor(fsy2); if(sy1-fsy1 1e-3){ assert(k len ); assert(sy1-1 =0); ofs .di = dy *width; ofs .si = sy1 -1; ofs .alpha =(sy1-fsy1)*scale; } for(int sy = sy1 ;sy sy2 ;sy++){ assert(k len ); assert(sy sheight ); ofs .di = dy *width; ofs .si = sy ; ofs .alpha = scale ; } if(fsy2-sy2 1e-3){ assert(k len ); assert(sy2 sheight ); ofs .di = dy *width; ofs .si = sy2 ; ofs .alpha =(fsy2-sy2)*scale; } } //delete ofs; } //mainfunction //takesadoublecolorimageandascalingfactor //returnsresizedimage mxArray*resize(constmxArray*mxsrc,constmxArray*mxscale){ double* src =(double*)mxGetPr(mxsrc); constint* sdims =(int*)mxGetDimensions(mxsrc); if(mxGetNumberOfDimensions(mxsrc)!=3|| mxGetClassID(mxsrc)!=mxDOUBLE_CLASS) mexErrMsgTxt("Invalidinput"); double scale = mxGetScalar (mxscale); if(scale 1) mexErrMsgTxt("Invalidscalingfactor"); intddims ; ddims =(int)round(sdims *scale); ddims =(int)round(sdims *scale); ddims =sdims ; mxArray* mxdst = mxCreateNumericArray (3,(mwSize*)ddims,mxDOUBLE_CLASS,mxREAL); double* dst =(double*)mxGetPr(mxdst); double* tmp =(double*)mxCalloc(ddims *sdims *sdims ,sizeof(double)); resize1dtran(src,sdims ,tmp,ddims ,sdims ,sdims ); resize1dtran(tmp,sdims ,dst,ddims ,ddims ,sdims ); mxFree(tmp); returnmxdst; } //matlabentrypoint // dst = resize (src,scale) //imageshouldbecolorwithdoublevalues voidmexFunction(intnlhs,mxArray*plhs ){ if(nrhs!=2) mexErrMsgTxt("Wrongnumberofinputs"); if(nlhs!=1) mexErrMsgTxt("Wrongnumberofoutputs"); plhs =resize(prhs ,prhs ); }
个人分类: DPM|4066 次阅读|0 个评论
[转载]Discriminatively Trained Deformable Part Models + Windows
hailuo0112 2013-2-19 14:17
至少是07年的东西,现在才来看,汗 去年在mac跑了一下,看了下效果,很不错。随便找了几张车的图片都检测到了 Windows下怎么跑异常简单: 1。pozen http://blog.csdn.net/pozen/article/details/7023742 2。dreamd1987 http://blog.csdn.net/dreamd1987/article/details/7396620 其中修改了resize.cpp,主要加了两个强制指针转换。 唯一补充是最后compile.m时还有个fconv.cc(75) : error C4716: 'process' : must return a value的错。把process返回值改成void就好(原来是void*)。或者随便返回一个指针,反正也没用 不知上面两位大虾是怎么跑通的:一切不明白都归到“平台差异” 我的是 W7+VS2012 64bit + Matlab 2009a 昨天把基本的demo跑通了,接下来顺理成章要学会训练了。先跑通原作者的步骤,再考虑训练自己的模型 参考的还是昨天两篇,另外加一片: 1. pozen http://blog.csdn.net/pozen/article/details/7103412 2. dreamd1987 http://blog.csdn.net/dreamd1987/article/details/7399151 3. liuwucn //http://hi.baidu.com/liuwucn/blog/item/77f3d2cf264bfae252664fb8.html http://hi.baidu.com/liuwucn/item/bf5d210c04e81497a2df431a 前人种树,后人copy。总结下我的步骤: 1。下载VOCdevkit和voc2011 dataset (http://pascallin.ecs.soton.ac.uk/challenges/VOC/voc2011/ ) data是个1.7G的tar file,Windows下直接用winrar解压还给搞死机了,不给力呀微软,微微有点软 2。修改global.m。上面3说的比较具体。 另外tmpdir要改,如果数据不在VOCdevkit的目录下还要改VOCinit.m中的路径,源文件中注释很清楚 3。修改train.m和rewritedat.m unix()---system() cp---copy ./learn---learn unix( ) ---delete(oldfile) unix( )---movefile(datfile, oldfile) (执行上面这条时总是说datfile已经被占用,在资源管理器里也改/删不了说被matlab占用,折腾了几个小时,自己好了,无语) 4。procid.m文件中的“/”修改为“\" 5。编译learn.cc 直接copy dreamd1987改好的code,easy! 6。pozen说的“rewritedat.m中还会出现下标越界的情况” 暂时没有改,训练似乎目前还没有问题 pascal('person', 3); 跑起了 训练真的很漫长。。。。
个人分类: DPM|0 个评论
Linux vs. Windows
ljxue 2013-1-31 00:55
The running environment of software is similar to the career development of human being. In Bioinformatics, many tools were designed for Linux user. You can find a particular tool working in Windows. It may work pretty well. However, if you want to build a complicated and powerful pipeline. More efforts are required in Windows, because you have no much supports from other existing tools. Choose a "correct" environment for you to put your mind of full.
个人分类: Live|2226 次阅读|0 个评论
电脑只是工具
热度 1 xiongjunlin 2013-1-22 21:40
Linux与Windows各有特色,在此分享一下我的看法。 当初尝试Linux,是因为听说Windows XP容易中病毒,容易蓝屏(虽然我的XP系统中病毒和蓝屏的次数屈指可数);而Linux却没有这些问题,且不用装杀毒软件。尝试Linux的过程中,给我印象最深的是LaTeX的编译速度比XP下的快太多了,没有等待的感觉,这让我对Linux生出一丝喜爱;随后又发现Emacs与AUCTeX搭配的编辑环境用起来实在太舒服了,特别喜欢其中的Alt-q功能,能够保持非常漂亮的LaTeX源文件。正是这两个原因促使我于2010年把工作环境转移到Ubuntu 10.04,随后又升级到12.04。 但是,Linux也不是都好。最让人不舒服的地方是没有word(这当然不是Linux的错)。由于Office 2003还是学校甚至是国家单位办公用的事实标准,我也时不时地需要使用Office 2003,例如写基金申请书、填学校文件。 最近,又发现Linux一个不完善的地方。事情是这样的。由于Ubuntu 12.04自带的LaTeX是texlive 2009,有点老了。于是,通过texlive-backports PPA将texlive 2009升级到texlive 2012,通过AUCTeX网站上的方法把AUCTeX升级到12.87。似乎一切都很顺利。但是当我用AUCTeX的view查看生成的PDF文件时,发现它不能把evince调到所有窗口的前面了,升级之前是可以的。也就是说,当在Emacs中用使用view命令时,得到的是没有任何反应。我相信通过“简单的”设置是可以解决这个问题的 ,但却发现自己已经没有折腾的劲头了,宁肯重装系统。 再说一下Windows平台。Windows 7给我的感觉是非常可靠,用起来让人省心。另外随着硬件的发展,操作系统本身似乎已经不是消耗电脑资源最多的程序了。唯一的遗憾也许还是当初我转用Linux的两点:Windows下编译LaTeX文件的速度依然很慢,Windows下依然没有匹敌Emacs的编辑环境。 言而总之,我对电脑的使用渐渐地趋于保守。一台电脑一旦配置完成,就不要再去折腾它了,因为你折腾的不是电脑,你折腾的是你自己;把精力放在工作上才是明智的。记住:电脑只是工具。
4797 次阅读|1 个评论
[转载]设置Cygwin可用的内存大小
ywmucn 2013-1-22 15:56
转自: http://linusky.bokee.com/viewdiary.13088833.html Cygwin默认的程序执行可用的内存为384MB, 如果要修改这个设置,可以添加注册表DWORD键HKEY_CURRENT_USER\Software\Cygnus Solutions\Cygwin\heap_chunk_in_mb(也可能是HKEY_LOCAL_MACHINE\Software\Cygnus Solutions\Cygwin\heap_chunk_in_mb ,或者两者均修改),然后再以MB为单位设置可用的内存大小(比如1023)。
个人分类: 集群&PC&Code|4685 次阅读|0 个评论
[转载]Windows放大镜快捷键大全 
yadon1983 2013-1-12 09:59
    Windows 键 + 符号键“+”   调用Windows7放大镜,并且放大局部内容     Windows 键 + 符号键“-”   调用Windows7放大镜,并且缩小局部内容     Windows 键 + Esc   退出放大镜     Ctrl + Alt + F   切换到全屏模式(Full screen mode)     Ctrl + Alt + L   切换到镜头模式(Len mode)     Ctrl + Alt + D   切换到停靠模式(Dock mode)     Ctrl + Alt + I   反色     Ctrl + Alt + 箭头键   按照箭头键方向平移(就是键盘控制移动方向)
1748 次阅读|0 个评论
[转载] Windows上igraph安装
xiaoxiao90 2013-1-10 15:55
一、iGraph的安装 igraph安装比较简单,直接在http://igraph.sourceforge.net/download.html下载python安装包即可。 后来我开始画图,发现报错,报错如下: raise TypeError("plotting not available") TypeError: plotting not available 在网络上搜索,找到如下解决方法,主要原因是igraph依赖的一个包没有装。安装方法如下 原文地址http://chuanwang66.iteye.com/blog/1704942 Graph plotting in igraph on Windows:cairo和dll被安装到C:\Python25\Lib\site-packages\cairo中 Graph plotting in igraph is implemented using a third-party package called Cairo . If you want to create publication-quality plots in igraph on Windows, you must also install Cairo and its Python bindings. The Cairo project does not provide pre-compiled binaries for Windows, but other projects depending on Cairo do, so the preferred way to install Cairo on Windows along with its Python bindings is as follows: Get the latest PyCairo for Windows installer from http://ftp.gnome.org/pub/gnome/binaries/win32/pycairo/1.8 . Make sure you grab the one that matches your Python version. At the time of writing, the above folder contained installers for Python 2.6 only. You may also try and go one level up, then down then 1.4 subfolder – these are older versions, but they work with Python 2.5 and Python 2.6 as well. Install PyCairo using theinstaller .(我用的是pycairo-1.4.12-2.win32-py2.5.exe) The installer extracts the necessary files into Lib\site-packages\cairo within the folder where Python is installed. Unfortunately there are some extra DLLs which are required to make Cairo work, so we have to get these as well. Head to http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/ and get the binary versions of Cairo ( cairo_1.8.10-3_win32.zip at the time of writing), Fontconfig ( fontconfig_2.8.0-2_win32.zip ), Freetype ( freetype_2.4.4-1_win32.zip ), Expat ( expat_2.0.1-1_win32.zip ), libpng ( libpng_1.4.3-1_win32.zip ) and zlib ( zlib_1.2.5-2_win32.zip ). Version numbers may vary, so be adaptive! Each ZIP file will contain a bin subfolder with a DLL file in it. Put the following DLLs in Lib\site-packages\cairo within your Python installation: freetype6.dll (from freetype_2.4.4-1_win32.zip ) libcairo-2.dll (from cairo_1.8.10-3_win32.zip ) libexpat-1.dll (from expat_2.0.1-1_win32.zip ) libfontconfig-1.dll (from fontconfig_2.8.0-2_win32.zip ) libpng14-14.dll (from libpng_1.4.3-1_win32.zip ) zlib1.dll (from zlib_1.2.5-2_win32.zip ). Having done that, you can launch Python again and check if it worked: Python代码 from igraph import * g=Graph.Famous( "petersen" ) plot(g) --------------------------------------------------------------------------------------------------------------------------------- 注意: 在运行时,我遇到了如下错误,最后发现时没有将cairo的dll加入环境变量path 下面是解决这个问题时参考的文档: 文档代码 Hi,IhavejustinstalledigraphandIamhavingaproblemwithplotting. Ihavefollowedtheinstructionsonthedocumentationsite http://www.cs.rhul.ac.uk/home/tamas/development/igraph/tutorial/install.html#graph-plotting-in-igraph-on-windows whichincludesinstallingpycairo,andputtingtherequireddllfilesinto Python2. 6 \Lib\site-packages\cairo igraphitselfhasinstalledproperly,asrunning importigraph.test igraph.test.test() givesnoerrors,andalltestswork. However,whenItrytorun fromigraphimport* g=Graph.Famous( "petersen" ) summary(g) plot(g) Igetthefollowingerror: Traceback(mostrecentcalllast): File "C:\DocumentsandSettings\fulford\Desktop\netstuff\test1.py" ,line 4 , inmodule plot(g) File "C:\Python26\lib\site-packages\igraph\drawing.py" ,line 762 ,inplot result=Plot(target,bbox) File "C:\Python26\lib\site-packages\igraph\drawing.py" ,line 222 ,in__init__ self._surface_was_created=notisinstance(target,cairo.Surface) File "C:\Python26\lib\site-packages\igraph\drawing.py" ,line 51 ,in __getattr__ raiseTypeError, "plottingnotavailable" TypeError:plottingnotavailable Ialsotriedthefollowing: importcairo butgottheerror: Traceback(mostrecentcalllast): File "pyshell#2" ,line 1 ,inmodule importcairo File "C:\Python26\lib\site-packages\cairo\__init__.py" ,line 1 ,inmodule from_cairoimport* ImportError:DLLloadfailed:Thespecifiedmodulecouldnotbefound. Iamfairlynewtopython,soamwonderingifthereissomethingelseIneeded todo,likeaddsomethingtomypathvariablesothatthedllfilesarefound? Anyhelporsuggestionsanyonecangivemewouldbemuchappreciated,sicveI wouldverymuchliketousethissoftware.. ThanksGlenn. PSplatformdetails: Platform:WindowsXP Pythonversion 2.6 ( 32 bitr)(enthoughtpythondistribution 6.2 ) DrGlennFulford+ 61 7 313 85196 QUTMathematicalSciences, GPOBox 2343 Brisbane,QldAUSTRALIA 4001 .Cricosno.00213J email:address@hidden; ------------------------------------------------------------------------------------- DearGlenn, ItseemslikethePythonbindingsofCairoarenotinstalledproperlyon yourmachine--igraphsimplyreportsthiswhenitsays"plottingnot available". IcheckedaworkinginstallationonWindowsXP( 32 -bit)andthe followingfilesshouldbepresentin c:\python26\lib\site-packages\cairo: __init__.py _cairo.pyd libcairo- 2 .dll libexpat- 1 .dll libfontconfig- 1 .dll libpng14- 14 .dll zlib1.dll TheerrormessageyouseemeansthatPythonfinds__init__.pyinthe cairosubfoldersuccessfully,andittriestoimport_cairo.pydfrom there.(.pydfilesarelikeordinary.dllfiles,Pythonjustusesa differentextensiontodistinguishthemfrom.dlls).Unfortunatelythe importcanfailforatleasttworeasons: 1 )_cairo.pyditselfismissing 2 )_cairo.pydisthere,butoneofitsdependenciesismissing. Unfortunately,theerrormessageisthesameinbothcases.So,I'ddo thefollowing: 1 .CheckwhetherallthefilesImentionedaboveareinthe site-packages\cairofolder.Ifnot,installthem. 2 .Iftheyareallthere,downloadDependencyWalkerfrom www.dependencywalker.comandopen_cairo.pydwithit.DependencyWalker shouldrecursivelytraversethedependencytreeof_cairo.pydandreport anyotherDLLsthatyouaremissing. -- Tamas ------------------------------------------------------------------------------------- DearTamas, thanksverymuchforyoursuggestions.IbeleiveIeventiuallytrackeddownthe problem. Ifoundthefollowingwebpageveryuseful. http://alex.matan.ca/install-cairo-wxpyton-pycairo-python-windows Firstthingittoldmewastoappendc:\Python26\Lib\site-packages\cairotomy path,whichIhadn 'tdone,butthisdidn' tfixtheproblem. Ithenreinstalledthedllfiles,thistimefromthewxpythionsite.Thiat seemedtofixtheproblem.Sonotsurreexactlywhichdllitwas,butIcan comparethemnifanyoneisinterested. Glenn 二、iGraph使用 参考这里 http://www.cs.rhul.ac.uk/home/tamas/development/igraph/tutorial/tutorial.html
个人分类: 技术积累|9628 次阅读|0 个评论
[转载]用Xming替代Xmanager,在windows下图形化登陆linux
plgongcat 2013-1-9 14:58
当我们想在windows下图形化登陆linux的时候,我们可以在linux下配置VNC服务,但这样有点儿麻烦。一些商业软件,比如Xmanager就可以利用SSH协议,来图形化登陆linux。 不过Xmanager是商业软件,现在我们使用一款开源的替代产品,Xming 下载地址: http://sourceforge.net/projects/xming/ 这里,Xming要配合putty使用,Xming只是起到一个运行在windows主机上的一个X-server,加密的通讯还是通过putty来执行。 具体步骤请看下面的链接地址吧。 转载: http://xiaosu.blog.51cto.com/2914416/723041
个人分类: unix|3600 次阅读|0 个评论
Windows平台上NCL的安装
yaozhixiong 2013-1-8 23:49
动力论坛上的一篇图文指导安装教程 很详细。 见 http://bbs.lasg.ac.cn/bbs/thread-37043-1-1.html ncl版本 5.1 自己安装了几次才成功。不管是自己,还是帖子里的回复,都有各式各样的安装错误提示。我想还是因为没有完全按照教程来安装。 大概出现的一些问题: 1. ncl版本 选择5.1 去 NCL下载地址: http://www.earthsystemgrid.org/ 上下载。 ncl_ncarg-5.1.0.CYGWIN_NT-5.1_i686.tar.gz 下载需要注册,而且会出现三个分类 (not OPeNDAP-enabled) OPeNDAP-enabled binaries source code 一个一个去里面找,就能找到。。试了刚出来的6.1版本,好像不行。不知道哪里除了问题 2. 细心,认真看教程。 帖子里的有些回复,都可以看出来不够细心。 比如,不能重复打开 X Server等等。 对linux的基本命令操作不熟悉。。。 (1)解压   cd /usr/local   gunzip /home/xxx/ncl_ncarg-5.1.0.CYGWIN_i686.tar.gz   tar -xvf /home/xxx/ncl_ncarg-5.1.0.CYGWIN_i686.tar (2)设置环境变量   export NCARG_ROOT=/usr/local   export PATH=/usr/local/bin:$PATH   export DISPLAY=:0.0
个人分类: linux|7703 次阅读|0 个评论
Windows下如何构建和发布Python模块
热度 3 Karrdy 2013-1-3 22:22
1. 首先将你要发布的模块(函数)写在一个Python文件里,即以*.py的文件,如nester.py文件(该文件内容即为你要发布的函数) 2. 创建一个文件夹如nester,将nester.py文件复制到该文件夹里 3. 在该文件夹里创建一个名为setup.py文件其内容为: from distutils.core import setup setup( #下面都是setup函数的参数名 name = 'nester', version = '1.0.0', #版本号 py_modules = , author = 'Karrdy', #作者 author_email = 'karrdykeung@gmail.com', url = 'http://www.headfristlabs.com', description = 'A simple printer of nester lists' #简介内容 ) 4. 构建一个发布文件 打开cmd,命令行将位置转到nester文件夹下,即在cmd里的c:\User\Administrator后敲入cd 你的nester文件夹位置 由于我把nester文件夹放在桌面上,所以是cd c:\User|Administrator\Desktop\nester回车 【其实有个简单的方法,在你cd加一空格后直接把nester文件夹用鼠标拖到cmd窗口,这样文件夹的位置就会直接显示 到里面,就不用一点一点敲了。】 接着在cmd里输入: 你的python.exe的位置,我的是放在D:\Python27\python.exe 所以输入的是 D:\Python27\python.exe setup.py sdist 回车之后会出现running sdist……不用管了,窗口不要关,下面还要用。 5. 将发布安装到你的Python本地副本中 任然在上面的窗口中输入: D:\Python27\python.exe setup.py install 回车就可以了,会出现running install……不用管了。 这样你要发布的模块就构建发布好了,也安装到你本地副本中了。 注:对于其他系统的电脑,如Mac和Unix和Linux系统的构建发布Python书上都有,请自己查看,不在赘述。
个人分类: 学习生活|14173 次阅读|5 个评论

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-20 20:26

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部