python numpy



def sigdr(inx):
    print type(inx)
    return sigmoid(inx)*(1-sigmoid(inx))
</pre><pre code_snippet_id="382622" snippet_file_name="blog_20140608_8_1502058" name="code" class="python">
</pre><pre code_snippet_id="382622" snippet_file_name="blog_20140608_8_1502058" name="code" class="python">
</pre><pre code_snippet_id="382622" snippet_file_name="blog_20140608_8_1502058" name="code" class="python">

x = mat(ones((2,2)))[1,:]
print x.A   //array 对应元素相乘
print 'sigmid ',sigdr(array(x))
m = mat(ones((3,2)))


import numpy as np
x = np.linspace(0, 10, 1000)
y = np.sin(x)
print y
a*a 点乘

dot(a,a)内积

from numpy import *
import numpy
from numpy import linalg as LA
m = mat(ones((3,2)))
ma = mat(ones((3,2)))
a1 = ones(3)+1 #1,3  one-dimention
a11 = ones((1,3))
a2 = ones((1,3))+1
a3 = ones((3,1))+1  #3,1  2-dimention
def squar(inx):
    return inx*inx
print squar(a1) #[ 4.  4.  4.]
print squar(a2) #[[ 4.  4.  4.]]
print squar(a3) #[[4][4][4]]
print shape(a1),shape(a11),shape(a3)  #(3,) (1, 3) (3, 1)
print a1*a3   #not error but not expected
print a11*a3  #not matrix output
a1m = mat(ones((1,3)))
a3m = mat(ones((3,1))+1)
print a1m*a3m    #return matrix [[6]]
print shape(a1m),shape(a3)
print a1m*a3     #matrix*2-dnarray ok
print a1m[0]  # [[ 1.  1.  1.]]
print a11[0]  # [ 1.  1.  1.]
#print a1m*a1  # erroe
#print squar(a1m) error

mm = mat([[1,2,3],[1,1,3]])
print mm[0].A[0].argmax()
print LA.norm(mm[0].A[0])
print mm+mat(ones((2,1)))


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值