文章目录
最近在coursera学习一系列课程,MATLAB和Python混着使,总是傻傻弄不清python里numpy的一些使用规则,所以直接贴一个在这里,好让自己查找:
参考网址: Numpy Manual v1.19
Coursera的notebook下载方式
参考博客
1.登陆进主界面
2.新建python notebook
3.输入:
!tar cvfz allfiles.tar.gz *
4.主界面会出现名叫:allfiles.gz的文件,点击并下载
PS 5.如果太大的话:(或者是下载不下来了,就是需要分开 再合起来…)
!split -b 200m allfiles.tar.gz allfiles.tar.gz.part.
然后全部下载好后,在cmd中
cat allfiles.tar.gz.part.* > allfiles.tar.gz
在window下命令有所不同,首先cd Desktop里
然后
copy /b utf-8''allfiles.tar.gz.part.* allfiles.tar.gz
在本地的Anaconda里下载opencv
问题:anaconda安装opencv Solving package specifications一直转圈圈
解决方法:
1、在anaconda prompt输入:
conda upgrade --all
2、等待一个done 全部完成
3、再次打开anaconda搜索opencv点击Apply(我是3mins左右就好了 继续apply 安装总共大概10mins就完成了)
重置Jupyter 还原最初状态
Rename your existing Jupyter Notebook within the individual notebook view
In the notebook view, add “?forceRefresh=true” to the end of your notebook URL
Reload the screen
You will be directed to your home Learner Workspace where you’ll see both old and new Notebook files.
Your Notebook lesson item will now launch to the fresh notebook.
首先点进去一份作业,保持在作业页,如图
重命名此程序名,如图,点确定
在浏览器最后加入:?forceRefresh=true
按下键盘Enter键,随后再次进入作业即可看到原来的初始作业。
matplotlib的图显示在Jupyter notebook里面/外面
%matplotlib inline
%matplotlib inline #显示在里面
plt.violinplot(dataset=np.random.randn(2000, 10)+ np.random.randn(10))# uniform distribution + np.random.randn(10))
plt.show()
%matplotlib qt
%matplotlib qt #显示在外面的交互界面
plt.violinplot(dataset=np.random.randn(2000, 10))# uniform distribution + np.random.randn(10))
plt.show()
numpy.zeros
numpy.zeros(shape, dtype=float, order=‘C’)
返回给定好row,clo内部全为零的数组
>>> np.zeros(5)
array([ 0., 0., 0., 0., 0.])
>>> np.zeros((5,), dtype=int)
array([0, 0, 0, 0, 0])
>>> np.zeros((2, 1))
array([[ 0.],
[ 0.]])
numpy.random.rand
numpy.random.rand(d0, d1, …, dn)
>>> np.random.rand(3,2)
array([[ 0.14022471, 0.96360618], #random
[ 0.37601032, 0.25528411], #random
[ 0.49313049, 0.94909878]]) #random
OS: 比如这里就和zeros,ones不一样了… 括号没了