![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python编程
文章平均质量分 57
我从崖边跌落
这个作者很懒,什么都没留下…
展开
-
【python】二维数组按照某行或某列排序(numpy lexsort)
曾经以为排序只能使用list的sort函数,后来发现array的排序实现方法也有很多。List1、一维数组2、二维数组无论是一维数组还是二维数组都能通过 list 自带的 sort() 函数进行更新,或者直接调用sorted()方法即可。import numpy as npa = [3,4,5,1,2,3]b = [[3,4,5],[2,3,4]]c = [[3,4,...原创 2018-12-17 20:40:41 · 65634 阅读 · 8 评论 -
【python】从数组随机取数据
在神经网络中,经常会用到批量样本训练。我们需要从数组随机取数据,主要有以下几种方法:1、np.random.shuffle:将原数组打乱import numpy as np array = np.random.randint(1,100,size=10)#[63 32 80 33 61 45 28 55 39 80]batch_size=5print(array[0:batc...原创 2019-07-25 21:50:33 · 27811 阅读 · 0 评论 -
【python】scipy中pdist和squareform
from scipy.spatial.distance import pdist, squareformpdist这是一个强大的计算距离的函数scipy.spatial.distance.pdist(X,metric='euclidean',*args,**kwargs)参数X:ndarrayAn m by n array of m original observ...原创 2019-06-29 21:47:49 · 27186 阅读 · 2 评论 -
【python】sklearn中PCA的使用方法
from sklearn.decomposition import PCAPCA主成分分析(Principal Components Analysis),简称PCA,是一种数据降维技术,用于数据预处理。PCA的一般步骤是:先对原始数据零均值化,然后求协方差矩阵,接着对协方差矩阵求特征向量和特征值,这些特征向量组成了新的特征空间。sklearn.decomposition.PC...原创 2019-07-09 23:01:53 · 115120 阅读 · 19 评论 -
【python】Python中glob.glob按照阿拉伯数字排序问题
python的glob模块,对自然数结尾的文件排序很奇怪,通过截取自然数的方式可以实现按照自然数大小排序原创 2019-06-24 22:07:15 · 15618 阅读 · 5 评论 -
【TensorFlow】RNN的用法汇总
一、单步的RNN:RnnCell1、tf.contrib.rnn.BasicRnnCell:RNN的一个单元细胞定义BasicRNNCell是最基本的RNN cell单元。1)函数介绍tf.contrib.rnn.BasicRnnCell(num_units,actication=None,reuse=None,name=None)输入参数:num_units:RNN层神经...原创 2019-04-03 17:23:02 · 1118 阅读 · 0 评论 -
【总结】【python】【TensorFlow】tensorflow常见的数据处理函数--机器学习,深度学习,强化学习
Numpy:1、numpy.random 链接numpy中的random主要是用来产生随机数的一个模块。2、numpy.newaxis链接numpy中的newaxis主要是帮助数组创建新轴,或者也叫增加维度。3、numpy.lexsort 链接numpy中的lexsort主要是对数组排序TensorFlow:1、tf.argmax(a,axis=)/tf.red...原创 2019-04-02 22:15:19 · 934 阅读 · 0 评论 -
【python】用 np.loadtxt() 读取txt文件
读取txt文件我们通常使用 numpy 中的 loadtxt()函数numpy.loadtxt(fname, dtype=, comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0)注:loadtxt的功能是读入数据文件,这里的数据文件要求每一行数据的格式相...原创 2019-04-10 21:16:32 · 52961 阅读 · 5 评论 -
【TensorFlow】tf.shape(a)和a.get_shape()的区别
1、区别:相同:都是用来获取数组的大小不同:tf.shape(a)的对象a为矩阵、列表或张量,结果为张量(tensor) a.get_shape()的对象a为张量(tensor),结果为元组,可以用a.get_shape().as_list()转为列表2、用法:1)tf.shape(a) 通过下面的例子,看两者在使用上的区别:import ...原创 2019-03-19 16:28:44 · 1162 阅读 · 0 评论 -
【python】numpy.random用法
numpy中的random主要是用来产生随机数的一个模块。模块使用中的常见问题:1、randn()和rand()的区别:numpy.random.randn(d0, d1, …, dn)是从标准正态分布(0均值1方差)中返回一个或多个样本值。 numpy.random.rand(d0, d1, …, dn)是从[0, 1)随机采样。(或者叫均匀分布采样)import nump...原创 2019-03-01 21:32:23 · 7835 阅读 · 0 评论 -
【python】numpy.newaxis的使用
作用 np.newaxis的作用是帮助数组创建新轴,或者也叫增加维度。np.newaxis 在使用和功能上等价于 None,其实就是 None 的一个别名。a= np.array([x for x in range(5)])print(a)print(a.shape)[0 1 2 3 4](5,)b = a[np.newaxis,:]print(b)p...原创 2018-10-23 20:43:37 · 3318 阅读 · 0 评论