1 Star 0 Fork 0

巨轮 / LearnMachineLearningInAction

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
hellonumpy.py 1.84 KB
一键复制 编辑 原始数据 按行查看 历史
巨轮 提交于 2020-08-15 22:39 . update c01 README.md
# -*- coding: utf-8 -*-
from numpy import *
array = random.rand(4, 4)
print array#随机4 * 4数组
print "----------------------------------------"
randMat = mat(array) #数组转换成矩阵
print randMat
print "----------------------------------------"
invRandMat = randMat.I #矩阵求逆
print invRandMat
print "----------------------------------------"
myEye = randMat * invRandMat#矩阵相乘
print myEye
print "----------------------------------------"
pure = myEye - eye(4, 4)#eye(4, 4) 创建单位矩阵
print pure
"""
[[0.59774478 0.27667655 0.83676654 0.34214905]
[0.15510116 0.34282224 0.67390717 0.82408148]
[0.74861786 0.72573314 0.76544715 0.04513842]
[0.73328569 0.08812684 0.72491471 0.48711059]]
----------------------------------------
[[0.59774478 0.27667655 0.83676654 0.34214905]
[0.15510116 0.34282224 0.67390717 0.82408148]
[0.74861786 0.72573314 0.76544715 0.04513842]
[0.73328569 0.08812684 0.72491471 0.48711059]]
----------------------------------------
[[-3.08488433 -0.49366735 1.05662269 2.90410042]
[-2.21556483 0.95867519 1.79791501 -0.23224319]
[ 5.28389187 -0.50394398 -1.44547134 -2.72492819]
[-2.81870016 1.319681 0.2352496 1.77838899]]
----------------------------------------
[[ 1.00000000e+00 1.11022302e-16 1.38777878e-17 1.11022302e-16]
[-4.44089210e-16 1.00000000e+00 1.38777878e-16 2.22044605e-16]
[-3.60822483e-16 2.08166817e-17 1.00000000e+00 -8.32667268e-17]
[-6.66133815e-16 1.11022302e-16 -1.66533454e-16 1.00000000e+00]]
----------------------------------------
[[ 0.00000000e+00 1.11022302e-16 1.38777878e-17 1.11022302e-16]
[-4.44089210e-16 0.00000000e+00 1.38777878e-16 2.22044605e-16]
[-3.60822483e-16 2.08166817e-17 -1.11022302e-16 -8.32667268e-17]
[-6.66133815e-16 1.11022302e-16 -1.66533454e-16 0.00000000e+00]]
"""
1
https://gitee.com/jallenkwong/LearnMachineLearningInAction.git
git@gitee.com:jallenkwong/LearnMachineLearningInAction.git
jallenkwong
LearnMachineLearningInAction
LearnMachineLearningInAction
master

搜索帮助