Python
机器学习的小学生
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python 库
Python 库下载:非官方的Window二进制文件 For Python Extension Packageshttp://www.lfd.uci.edu/~gohlke/pythonlibs/PyPI-the Python Package Index https://pypi.python.org/pypi原创 2017-02-04 14:23:01 · 505 阅读 · 0 评论 -
python 列表推导式
例子1:### 列表推导式#coding=gbkimport numpy as npimport matplotlib.pyplot as pltimport scipy.io as sio # loadmatmysolver = list()mysolver0 = list()niter = 10solver = [('pretrained',mysolver),('scratch',m原创 2017-06-25 10:14:47 · 770 阅读 · 0 评论 -
python 常用库的安装
读图片from scipy.misc.pilutil import * # read imageimg = imread('lena.jpg')其是通过PIL的Image类实现的读图片功能,因此安装scipy库的同时也要安装PIL库.dlib for python2.7例如利用dlib库中的人脸检测算法。conda install -c menpo dlib=18.18原创 2017-06-15 15:08:08 · 1662 阅读 · 0 评论 -
caffe 定义自己的python层
因为caffe底层是用c++编写的,所以我们有的时候想要添加某一个最新文献出来的新算法,正常的方法是直接编写c++网络层,然而这个有个前提条件是必须对caffe的底层非常熟悉,c++的编写达到一定的境界,才可灵活应用caffe,搞深度学习,走这条路对于菜鸟来说无疑很有难度。好在caffe为我们提供了一个可以用python编写新的网络层的方法,直接用python语言编写新的网络层,然后在caffe的网原创 2017-06-14 16:19:22 · 2852 阅读 · 2 评论 -
参数的初始化
训练自己的神经网络中,参数W和b的初始化:W = 0.01 * np.random.randn(D,K) # D是维数,K是类别数b = np.zeros((1,K))参考文献 13 CS231 Training a Simple Neural Network原创 2017-09-07 11:19:17 · 1293 阅读 · 0 评论 -
python 创建类cell数组
When you do this:a = np.array([[np.array([[2, 2]]), np.array([[3, 3]])]])the final call to np.array actually concatenates the inner two, so you get one array at the end:>>> aarray([[[[2, 2]], [原创 2017-09-18 10:44:38 · 17787 阅读 · 3 评论 -
np.save 和 sio.savemat 简单的比较
#coding=gbkimport numpy as npimport scipy.io as sio # mat# 对两种save 方法进行比较# 比较结果,同样的数据,通过.mat 存储后在导入变成了二维的,因为matlab对[4,]和[1,4]没有区别,但python有区别。# 结论,所以使用的时候要注意些。arr1 = np.array([1,2,3,4])arr2 = np.a原创 2017-10-27 20:11:01 · 15904 阅读 · 0 评论 -
将tensorflow的ckpt模型存储为npy
#coding=gbkimport numpy as npimport tensorflow as tffrom tensorflow.python import pywrap_tensorflowcheckpoint_path='model.ckpt-5000'#your ckpt pathreader=pywrap_tensorflow.NewCheckpointReader(ch原创 2018-01-16 15:48:03 · 7149 阅读 · 3 评论 -
Python一些基础知识
python 中[…]# coding=gbk'''Created on 2017年5月9日'''from scipy.misc.pilutil import * # read image ,read 会提示错误,但是不影响使用import matplotlib.pyplot as plt # show image import numpy as np # 两个方法都用...原创 2017-05-09 17:04:44 · 950 阅读 · 0 评论 -
Python savefig 去掉白色的margin
import matplotlib.pyplot as pltfig = plt.figure(frameon=False)fig.set_size_inches(w,h)ax = plt.Axes(fig, [0., 0., 1., 1.])ax.set_axis_off()fig.add_axes(ax)ax.imshow(your_image, aspect='normal')...原创 2018-05-16 15:21:05 · 5511 阅读 · 0 评论 -
将int类型的数组转换为bool数组 in Python
#coding=UTF-8import numpy as np# int arrayarray1 = np.array([1,0,1,0])# convert int array to bool listlist1 = [True if array1[i]==0 else False for i in range(len(array1))]# convert bool list t...原创 2018-07-07 10:02:47 · 9292 阅读 · 2 评论 -
python sys.path.append()和sys.path.insert()
转载自: https://blog.youkuaiyun.com/dcrmg/article/details/79546962python程序中使用 import XXX 时,python解析器会在当前目录、已安装和第三方模块中搜索 xxx,如果都搜索不到就会报错。 使用sys.path.append()方法可以临时添加搜索路径,方便更简洁的import其他包和模块。这种方法导入的路径会在python程...转载 2018-09-04 21:04:18 · 4015 阅读 · 2 评论 -
Real-time plotting in Python and Matlab
Python:import matplotlib.pyplot as pltimport numpy as npplt.ion() ## Note this correctionfig=plt.figure()#plt.axis([0,1000,0,1])i=0x=list()y=list()while i <1000: temp_y=np.random.random();原创 2017-05-23 10:01:57 · 1147 阅读 · 0 评论 -
python进程池:multiprocessing.pool
转载自: http://www.cnblogs.com/kaituorensheng/p/4465768.html在利用Python进行系统管理的时候,特别是同时操作多个文件目录,或者远程控制多台主机,并行操作可以节约大量的时间。当被操作对象数目不大时,可以直接利用multiprocessing中的Process动态成生多个进程,十几个还好,但如果是上百个,上千个目标,手动的去限制进程数量却又太过转载 2017-06-17 21:12:04 · 1145 阅读 · 0 评论 -
Anaconda 和Miniconda 镜像库
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/原创 2017-03-06 10:15:55 · 3309 阅读 · 0 评论 -
matlab与python 语言区别总结(1)
转自: http://blog.youkuaiyun.com/bluebelfast/article/details/17612537 现在学术界越来越多人使用Python 语言取代Matlab 作为研究的主要程序编写工具。python语言看似有点类似matlab语言,对于习惯Matlab 的使用者来说,转换到Python语言应该并不困难,但是有些关键要注意的地方,也就是这两种语言的差别。掌握了两种转载 2017-05-04 16:15:52 · 8483 阅读 · 0 评论 -
python 读取并显示图片的两种方法
转自: http://www.cnblogs.com/yinxiangnan-charles/p/5928689.html在 python 中除了用 opencv,也可以用 matplotlib 和 PIL 这两个库操作图片。本人偏爱 matpoltlib,因为它的语法更像 matlab。一、matplotlib1. 显示图片import matplotlib.pyplot as plt # plt转载 2017-04-23 11:10:02 · 10169 阅读 · 2 评论 -
caffe的matlab和python接口数据的处理
Python: arr = np.load('ilsvrc_2012_mean.npy')print arr.shape # (3,256,256) channel * height * width########## 数据的转置 ###############arr = np.transpose(arr,[1,2,0]) # height * width * channelprint arr.sh原创 2017-05-13 15:47:59 · 882 阅读 · 0 评论 -
均值文件
均值文件的读取: ilsvrc_2012_mean.npyarr = np.load('ilsvrc_2012_mean.npy')print arr.shape # (3,256,256) channel * height * width########## 数据的转置 ###############arr = np.transpose(arr,(1,2,0)) # height * width原创 2017-05-13 15:32:43 · 1201 阅读 · 0 评论 -
Python 中括号的使用(1)
转自:http://blog.youkuaiyun.com/linda1000/article/details/8152714Python中括号的使用学习了那么久,最近终于开始使用python进行系统编程,发现学习跟实际操作还是有很大区别的,尤其用到元组,列表等数据的时候,具体改用中括号,圆括号,还是大括号,都混乱了,上网查了下,根据实际应用,稍微做下分析总结:1. 列表list是用[ ]包住的以逗号分转载 2017-04-24 10:20:22 · 7499 阅读 · 0 评论 -
Python:双斜线操作符//
http://stackoverflow.com/questions/1535596/what-is-the-reason-for-having-in-python原创 2017-04-24 10:48:20 · 9611 阅读 · 0 评论 -
np transpose
测试np中数组的转置操作:# coding=gbk'''Created on 2017年5月9日'''from scipy.misc.pilutil import * # read image import matplotlib.pyplot as plt # show image import numpy as np # 两个方法都用from numpy import *######原创 2017-05-09 15:22:02 · 1310 阅读 · 0 评论 -
prepare hdf5 data for training
Matlab:“`matlab% hdf5_file_2 clearvars;load train_data_2.mat;load mean_file.mat ; % load mean_filetrain_feat = [train_data{1};train_data{2};train_data{3};train_data{4}];test_feat = train_data{5} ;%%%%%原创 2017-05-18 20:47:52 · 803 阅读 · 0 评论 -
python 读取 mat 文件
详细参考:https://docs.scipy.org/doc/scipy/reference/tutorial/io.html(1) mat4py库:功能: 将Matlab 数据导入为基本的Python数据类型。矩阵是以行为组的存储方式(使用列表的列表)。 Matlab结构体Struct和元胞Cell 使用Python的词典表示。Load data from MAT-file:函...原创 2017-05-19 16:18:14 · 53380 阅读 · 0 评论 -
python 和 matlab
Python Matlab 功能 str.replace(old,new[,count]) dstStr= strrep(origStr,oldSubstr,newSubStr) filepath = 'E:/data/1.jpg'; filepath2 = strrep(filepath,'data','lfw/data');disp(filepath2); 替原创 2017-05-19 15:32:30 · 1433 阅读 · 0 评论 -
Python中os与sys两模块的区别
os与sys模块的官方解释如下:os: This module provides a portable way of using operating system dependent functionality.这个模块提供了一种方便的使用操作系统函数的方法。sys: This module provides access to some variables used or maintained b转载 2017-06-16 19:53:28 · 841 阅读 · 0 评论 -
在python的单个脚本中顺序的执行批量的脚本
#coding=gbkimport sysimport train_task1sys.modules['train_task1'].__dict__.clear()import train_task2sys.modules['train_task2'].__dict__.clear()import train_task3sys.modules['train_task3']...原创 2018-10-10 13:53:15 · 3067 阅读 · 0 评论
分享