python
byres
这个作者很懒,什么都没留下…
展开
-
Python 中的“二维”字典 (two-dimension dictionary)
Python 中的dict可以实现迅速查找。那么有没有像数组有二维数组一样,有二维的字典呢?比如我需要对两个关键词进行查找的时候。一维的字典新添一个”key-value”对(比如key为字符’a’,value为1),可以用adict = dict()adict['a'] = 1或者adict.update({'a': 1})但是”二维”字典新添一个”key-value”对时,不能简单的用adict原创 2015-08-05 02:19:31 · 48382 阅读 · 0 评论 -
Python中找list中最大n个数的包heapq.nlargest
from heapq import nlargest a = [0.2, 0.9, 0.5, 1.1, 1.5, 2.3]print nlargest(4, a) #从list a中找出最大的四个数原创 2016-06-18 15:59:53 · 6188 阅读 · 0 评论 -
save and load nueral network parameters when using python lasagne
import cPickle as picklesys.setrecursionlimit(10000) # you may need this if the network is largewith open("model_file", 'wb') as f: pickle.dump(nolearnnet , f, -1)但是,如果据说在GPU上训练的神经网络要用读取出来用CPU做计翻译 2017-04-04 15:53:42 · 391 阅读 · 0 评论