摘要: 装饰器的作用是在原有对象的基础上添加额外功能。python中可以将函数作为参 数,进行装饰,返回经过修饰过的函数,比如:def decorator(fn): def wrapper(): print "*** wrapper ***" fn() pri... 阅读全文
posted @ 2015-06-22 15:46 登山者 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 上下文管理器(context manager)是Python2.5开始支持的一种语法,用于处理指 定代码块进入和退出时的操作。一般使用with语法,也可以直接调用相应的方法。with语句with语句是用来简化“try/finally”语句的,通常用于处理共享资源的获取和释放,比如文件、数据库和线程资... 阅读全文
posted @ 2015-06-22 15:44 登山者 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 在python中一个描述器就是定义下面的方法中一个或多个的一个对象:__get__(self, instance, owner)t__set__(self, instance, value)__delete__(self, instance)如果一个对象同时定义了__get__()和__set__(... 阅读全文
posted @ 2015-06-22 15:42 登山者 阅读(292) 评论(0) 推荐(0) 编辑
摘要: A*算法是一种经典的启发式搜索算法,公式表示为:f(n)=g(n)+h(n),其中f(n) 是从初始点到目标点的估价函数,g(n)是从初始点到节点n的代价,h(n)是从节 点n到目标节点的估计代价,保证找到最短路径关键在于估价函数h(n)的选取。一、几个相关知识:启发式搜索:启发式搜索就是在状态空间... 阅读全文
posted @ 2015-06-22 15:40 登山者 阅读(1018) 评论(0) 推荐(0) 编辑
摘要: While individuals operating individually can choose whatever values and principles they like, when working in a group the people must agree on the gro... 阅读全文
posted @ 2015-06-22 15:37 登山者 阅读(315) 评论(0) 推荐(0) 编辑
摘要: Part 1 && Part2It isn't easy for me to be confident that my opinions are right.Bad opinions can be very costly.The consensus is often wrong, so I have... 阅读全文
posted @ 2015-06-22 15:35 登山者 阅读(279) 评论(0) 推荐(0) 编辑
摘要: 生成器是可以当作iterator使用的特殊函数。它有以下优点:1. 惰性求值;2. 在处理大的列表时不需要一次性加载全部数据,可以减小内存使用;除非特殊的原因,应该在代码中使用生成器。生成器(generator) vs 函数(function)生成器和函数的主要区别在于函数return a valu... 阅读全文
posted @ 2015-06-22 15:30 登山者 阅读(207) 评论(0) 推荐(0) 编辑
摘要: 1. ones(X) ones(N, M)% return a matrix or N-dimensional array whose elements are all 1.2. zeros(X) zeros(N, M)% return a matrix or N-dimensional array whose elements are all 0.3. rand(X) rand(N, M)% return a matrix with random elements uniformly distributed on the interval (0,1).4. hist(Y, X, NORM)% 阅读全文
posted @ 2014-01-21 23:29 登山者 阅读(265) 评论(0) 推荐(0) 编辑
摘要: 移动C-f forword-char 光标向前移动一个字符C-b backword-char 光标向后移动一个字符C-M-f paredit-forward 光标移动到括号后(foo |(bar baz) quux)(foo (bar baz)| quux)(foo (bar)|)(foo (bar))|C-M-b paredit-backword 光标一定到括号前(foo (bar baz)| quux)(foo |(bar baz) quux)(| (foo) bar)|((foo) bar)C-a 移动至行首C-e 移动至行尾编辑C-M-Space mark-sexp 选中光标所在的.. 阅读全文
posted @ 2014-01-21 22:59 登山者 阅读(944) 评论(0) 推荐(0) 编辑
摘要: * lrCostFunction.mfunction [J, grad] = lrCostFunction(theta, X, y, lambda)%LRCOSTFUNCTION Compute cost and gradient for logistic regression with %regularization% J = LRCOSTFUNCTION(theta, X, y, lambda) computes the cost of using% theta as the parameter for regularized logistic regression and the... 阅读全文
posted @ 2013-11-24 16:57 登山者 阅读(3758) 评论(0) 推荐(0) 编辑