随笔分类 -  Python

摘要:github:https://github.com/zle1992/Seq2Seq-Chatbot 1、 注意在infer阶段,需要需要reuse, 2、If you are using the BeamSearchDecoder with a cell wrapped in AttentionWr 阅读全文
posted @ 2019-03-27 16:18 乐乐章 阅读(1542) 评论(0) 推荐(1)
摘要:Deque objects support the following methods: Add x to the right side of the deque. Add x to the left side of the deque. Remove all elements from the d 阅读全文
posted @ 2019-01-17 16:18 乐乐章 阅读(221) 评论(0) 推荐(0)
摘要:和 threading 的比较 多进程 Multiprocessing 和多线程 threading 类似, 他们都是在 python 中用来并行运算的. 不过既然有了 threading, 为什么 Python 还要出一个 multiprocessing 呢? 原因很简单, 就是用来弥补 thre 阅读全文
posted @ 2019-01-10 22:25 乐乐章 阅读(415) 评论(0) 推荐(0)
摘要:thread 在数据预处理的时候用处不大,因为有GIL 锁 查看thread信息 定义thread job并开启 join()的功能 先运行join的功能,然后再运行join 下面的。 注释掉 19、20 你也可以添加thread_2.join()进行尝试,但为了规避不必要的麻烦,推荐如下这种122 阅读全文
posted @ 2019-01-10 19:00 乐乐章 阅读(458) 评论(0) 推荐(0)
摘要:1 def cal_sim2(A,B): 2 ''' 3 A :query [1,2] 4 B: answers [[1,2],[3,5]] 5 ''' 6 need_norm=False 7 A = np.array(A) 8 B = np.array(B) 9 A=A/np.linalg.norm(A... 阅读全文
posted @ 2018-12-07 16:03 乐乐章 阅读(792) 评论(0) 推荐(0)
摘要:用python实现一个简单的socket网络聊天通讯 (Linux --py2.7平台与windows--py3.6平台) 人生苦短之我用Python篇(socket编程) python之路 socket、socket server http://www.runoob.com/python/pyth 阅读全文
posted @ 2018-12-05 22:34 乐乐章 阅读(157) 评论(0) 推荐(0)
摘要:需求 给定一个list 针对list 中每个元素执行一定的操作(这个操作很费时间,例如爬数据的时候调用某个网站的接口),返回操作后的list 例如 给定 1-10个数,在每个数字后面加个字母a 方法 1、利用线程池pool 及map 函数 实现 结论: 可以发现 运行时间缩短了。一定要保证所执行的函 阅读全文
posted @ 2018-02-08 14:14 乐乐章 阅读(905) 评论(0) 推荐(0)
摘要:利用上一篇得到的城市经纬度算城市距离 阅读全文
posted @ 2017-07-20 10:46 乐乐章 阅读(2143) 评论(0) 推荐(0)
摘要:有2种方式,第一种是利用urllib , 方法1:利用urllib , 先把url 转成urlcode,然后读取网页,读到网页再用json读取内容,比较麻烦。 可以在浏览器输入,看一下格式。 2.将查询转换为urlcode 读取网页内容: 读取json数据: 程序: 方法二:利用request模块, 阅读全文
posted @ 2017-07-20 10:43 乐乐章 阅读(8015) 评论(1) 推荐(0)
摘要:先根据Ubuntu预装的python2.7来安装Anaconda2,然后将Anaconda3作为其环境安装在envs文件夹下。 重要提示:有一些软件需要py2.7的环境,比如XX-Net, 最好是先安装Anaconda2,这样系统默认的环境是py2,然后再安装Anaconda3。需要py3环境时,用 阅读全文
posted @ 2017-04-16 22:40 乐乐章 阅读(16540) 评论(0) 推荐(0)
摘要:SVD在餐馆菜肴推荐系统中的应用 摘要:餐馆可以分为很多类别,比如中式、美式、日式等等。但是这些类别不一定够用,有的人喜欢混合类别。对用户对菜肴的点评数据进行分析,可以提取出区分菜品的真正因素,利用这些因素我们可以估计人们对没去过的餐厅的看法。提取这些信息的方法就是SVD(Singular Valu 阅读全文
posted @ 2017-01-12 13:10 乐乐章 阅读(1068) 评论(0) 推荐(0)
摘要:使用python对列表(list)进行排序,说简单也简单,说复杂也复杂,我一开始学的时候也搞不懂在说什么,只能搜索一些英文文章看看讲解,现在积累了一些经验,写在这里跟大家分享,我们通过例子来详细解释一下函数sorted的具体用法: 先创建一个列表a 直接使用sorted方法,返回一个列表就是排序好的 阅读全文
posted @ 2017-01-10 22:35 乐乐章 阅读(89874) 评论(6) 推荐(20)
摘要:2.文本文件的写入 Python代码 import fileinput file = open("D:\\test.txt", encoding="utf-8",mode="w") file.write("朝八晚十\n") file.close() with open("D:\\test.txt", 阅读全文
posted @ 2016-12-06 16:38 乐乐章 阅读(10028) 评论(0) 推荐(0)
摘要:Using the numpy.hstack will create an array with two sparse matrix objects. scipy.sparse.bmat 归一化 norm : ‘l1’, ‘l2’, or ‘max’, optional (‘l2’ by defau 阅读全文
posted @ 2016-11-09 12:58 乐乐章 阅读(2904) 评论(0) 推荐(1)
摘要:文本提取特征常用的模型有:1.Bag-of-words:最原始的特征集,一个单词/分词就是一个特征。往往一个数据集就会有上万个特征;有一些简单的指标可以帮助筛选掉一些对分类没帮助的词语,例如去停词,计算互信息熵等等,但不管怎么训练,特征维度都很大,每个特征的信息量太小;2.统计特征:包括Term f 阅读全文
posted @ 2016-11-08 11:30 乐乐章 阅读(1372) 评论(0) 推荐(0)
摘要:1 GridSearch 2search 3 阅读全文
posted @ 2016-11-03 16:39 乐乐章 阅读(934) 评论(0) 推荐(0)
摘要:组合分类器: 组合分类器有4种方法: (1)通过处理训练数据集。如baging boosting (2)通过处理输入特征。如 Random forest (3)通过处理类标号。error_correcting output coding (4)通过处理学习算法。如voting 1 bagging 2 阅读全文
posted @ 2016-11-03 16:28 乐乐章 阅读(1331) 评论(0) 推荐(0)
摘要:numpy.linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None) a=np.linspace(1000,320000,num=32,dtype=int) 阅读全文
posted @ 2016-11-03 14:51 乐乐章 阅读(662) 评论(0) 推荐(0)
摘要:在程序的开头加上如上代码 https://docs.scipy.org/doc/numpy/reference/generated/numpy.linspace.html 阅读全文
posted @ 2016-11-03 14:29 乐乐章 阅读(4153) 评论(0) 推荐(1)
摘要:读取csv文件: 1 import csv 2 #打开文件,用with打开可以不用去特意关闭file了,python3不支持file()打开文件,只能用open() 3 with open("XXX.csv","r",encoding="utf-8") as csvfile: 4 #读取csv文件, 阅读全文
posted @ 2016-10-21 22:45 乐乐章 阅读(13674) 评论(0) 推荐(0)