
Python
j-o-l-i-n
半路出家机房扫地僧,沉迷火炉炼丹和修仙。精通徒手写bug,曾出版《如何一秒爆显存》。
展开
-
NLP之路-warm up
今天做了一些小的尝试,算作技术铺垫原创 2014-09-28 17:14:17 · 1152 阅读 · 0 评论 -
theano中的index好怪异。。比如最大似然估计的损失计算部分。
# NLL is a symbolic variable ; to get the actual value of NLL, this symbolic # expression has to be compiled into a Theano function (see the Theano # tutorial for more details) NLL = -T.sum(T转载 2016-07-13 14:26:46 · 450 阅读 · 0 评论 -
给公司的电脑配置theano
anaconda安装的pythonpip install theano安装theano输入import theano遇到warning提示没有找到g++conda install mingw输入import theano遇到报错屏幕爆炸,其中提示Problem occurred during compilation with the command line below:D:\原创 2016-07-05 11:44:22 · 506 阅读 · 0 评论 -
在实验室服务器毫无阻拦的安装pip3
curl "https://bootstrap.pypa.io/3.2/get-pip.py" -o "get-pip.py"sudo python3 get-pip.py原创 2016-07-27 17:38:01 · 900 阅读 · 0 评论 -
pycharm远程调试报错cant ser remote tunneling
一开始就报错cant ser remote tunneling就把远程的etc/ssh/sshd_config里面的AllowTcpForwarding改成yes然后service sshd restart 还是不行!!!后来找到python console上面有好多好多错误,最后一行显示的是traitlets.traitlets.TraitError: No default va原创 2016-07-06 17:29:02 · 1288 阅读 · 0 评论 -
Python中函数的参数传递与可变长参数
http://www.cnblogs.com/xudong-bupt/p/3833933.html1.Python中也有像C++一样的默认缺省函数1 def foo(text,num=0):2 print text,num3 4 foo("asd") #asd 05 foo("def",100) #def 100定义有默认参数的函数时,这些默认值转载 2016-08-23 15:13:58 · 456 阅读 · 0 评论 -
换了一种管用pip安装方法,还有管用的python版hdf5(包名为h5py)安装方法
pip:之前在stackoverflow上找到一个方法,下载了一个get-pip.py的脚本进行安装的,但是一旦pip install --upgrade pip,就会报错syntax error。这次也是stackoverflow上的方法,彻底解决了之前的问题。 下载https://pypi.python.org/packages/2.7/s/setuptools/setuptoo原创 2016-08-24 11:35:53 · 11103 阅读 · 0 评论 -
解决linux的screen中gpu无法在theano中正常启用的问题
http://stackoverflow.com/questions/36781461/how-to-use-theano-within-screen-sessionI use theano on a remote server that I first ssh into (I don't have root on that system). This works fine, howeve转载 2016-09-20 01:05:47 · 1411 阅读 · 0 评论 -
windows上配置新的conda env+torch
conda create -n myenv scipy nb_conda -c peterjc123 torchpip install torchvision原创 2017-07-05 15:25:45 · 851 阅读 · 0 评论 -
解决Pycharm里远程调试缺乏DISPLAY环境变量的TkAgg报错
错误: TclError: no display name and no $DISPLAY environment variable Backend TkAgg is interactive backend. Turning interactive mode on.解决: 随便一个靠前的代码里加入import matplotlibmatplotlib.use('Agg')原创 2017-08-21 00:46:40 · 9608 阅读 · 2 评论 -
Install Rouge and Pyrouge for python 2.7 (conda virtual env) on Linux 64
Install Rouge and PyrougeStep 1: Create a new conda virtual envconda create -n py27env python=2.7 pipsource activate py27env# use " source deactivate" to deactivate the env原创 2017-08-23 17:32:48 · 2599 阅读 · 0 评论 -
配置jupyter notebook到conda env虚拟环境里可运行
python -m ipykernel install --user --name env_name原创 2018-06-19 23:04:44 · 1751 阅读 · 0 评论 -
Why I can't reproduce my results
1. Pytorch's CPU's and GPU's seeds are independent. So set/save/load them independentlyhttps://discuss.pytorch.org/t/are-gpu-and-cpu-random-seeds-independent/1422. If you use randomness on several...原创 2019-02-16 13:51:49 · 227 阅读 · 0 评论 -
用nohup重定向python输出到文件不成功的解决办法
原因是:It looks like you need to flush stdout periodically (e.g. sys.stdout.flush()). In my testing Python doesn't automatically do this even with print until the program exits.You can run Python wit原创 2016-05-15 21:25:38 · 3601 阅读 · 0 评论 -
如何用python一个字一个字的输出汉字
for z in zi.decode('utf-8'): print(z.encode('utf-8'))原创 2016-05-12 19:17:48 · 13641 阅读 · 2 评论 -
NLP之路-python爬虫
解决了IDE中文显示的问题,通过print(soup.head.title).encode('gb18030')解决了中文路径无法打开的问题,通过file=open(u"D:/users/nancy/share/sae6depart/6系资料/python/crawl.txt","w")import urllibfrom urllib import urlopenc=urrllib.u原创 2014-09-27 15:37:23 · 1256 阅读 · 0 评论 -
Startup Script for Python(x,y)
碰巧在C:\Users\你的用户名\.ipython\profile_pysh\startup\文件夹下找到了README,里面写得很清楚,只要在此文件夹下放若干个.py文件,则会在ipython启动前执行这些文件(按照字母表顺序执行,如果有多个.py文件的话)。所以你就可以在这里各种import XXX as XX了。原创 2014-09-28 11:14:30 · 870 阅读 · 0 评论 -
NLP之路-查看获取文本语料库
继续学习NLP in Python#coding=UTF-8#上面一句解决中文注释编码错误问题import nltk#查看获取到的文本语料库nltk.corpus.gutenberg.fileids()#给书名附一个简短的名字emmaemma=nltk.corpus.gutenberg.words('austen-emma.txt')#192427len(emma)#同样利用原创 2014-09-30 11:19:59 · 1664 阅读 · 0 评论 -
在NPP运行Python报错:SyntaxError: Non-ASCII character '\xe5' in file的解决方法
SyntaxError: Non-ASCII character '\xe5' in file原创 2014-09-30 11:10:33 · 874 阅读 · 0 评论 -
NLP之路-实验nltk中的raw 和 words
原创 2014-10-02 17:41:09 · 1101 阅读 · 0 评论 -
将Notepad++配置为Python编译器
先看一下预期效果:原创 2014-09-28 01:37:23 · 2130 阅读 · 0 评论 -
NLP之路-继续书本上的实验
#coding=utf-8import nltkfrom nltk.corpus import brownnews_text=brown.words(categories='news')fdist=nltk.FreqDist([w.lower() for w in news_text])modals1=['can', 'could', 'may','might','mu原创 2014-10-02 22:40:34 · 482 阅读 · 0 评论 -
NLP之路-一点小语言工具函数
统计工具#coding=utf-8def lexical_diversity(my_text_data): word_count=len(my_text_data) vocal_size=len(set(my_text_data)) diversity_score=word_count/vocal_size return diversity_score my_text_data=原创 2014-10-10 21:23:09 · 798 阅读 · 0 评论 -
crfpp python
本文运用字标注法进行中文分词,使用4-tag对语料进行字标注,观察分词效果。模型方面选用开源的条件随机场工具包“CRF++: Yet Another CRF toolkit”进行分词。 本文使用的中文语料资源是SIGHAN提供的backoff 2005语料,目前封闭测试最好的结果是4-tag+CFR标注分词,在北大语料库上可以在准确率,召回率以及F值上达到92%以上的效果,在转载 2016-01-07 19:46:06 · 6138 阅读 · 1 评论 -
anaconda windows theano keras 完全安装教程,没有gpu忽略那段话也成功了
http://datanoord.com/2016/02/01/setup-a-deep-learning-environment-on-windows-theano-keras-with-gpu-enabled/转载 2016-04-08 17:15:38 · 1888 阅读 · 0 评论 -
scikit-learn中PCA的使用方法
http://blog.youkuaiyun.com/u012162613/article/details/42192293转载 2016-04-26 00:39:06 · 467 阅读 · 0 评论 -
How can I force Python's file.write() to use the same newline format in Windows as in Linux (“\r\n”
https://www.google.com/#q=write+lf+instead+of+crlf+python转载 2016-05-11 17:20:35 · 568 阅读 · 0 评论 -
从Theano到Lasagne:基于Python的深度学习的框架和库
http://www.youkuaiyun.com/article/2015-08-01/2825362?reload=1转载 2016-04-30 22:19:59 · 444 阅读 · 0 评论 -
python built-in cache (don't reinvent the wheel)
@functools.lru_cachedef func(): ...very useful for loading/rolling out huge image features.原创 2019-02-16 16:39:56 · 312 阅读 · 0 评论