随笔 - 1762  文章 - 0  评论 - 109  阅读 - 431万

随笔分类 -  Python

上一页 1 2 3 4 5 6 7 ··· 12 下一页
如何在NumPy中创建空数组/矩阵?python建立空的ndarray
摘要:在添加行的情况下,你最好的选择是创建一个与数据集最终一样大的数组,然后向它添加数据 row-by-row: >>> import numpy >>> a = numpy.zeros(shape=(5,2)) >>> a array([[ 0., 0.], [ 0., 0.], [ 0., 0.], 阅读全文
posted @ 2021-09-28 10:14 一杯明月 阅读(3052) 评论(0) 推荐(0) 编辑
python更新平均值
摘要:def addToAverage(average, size, value): ''' The following function adds a number to an average. average is the current average, size is the current nu 阅读全文
posted @ 2021-09-06 22:14 一杯明月 阅读(62) 评论(0) 推荐(0) 编辑
python打开文件,python写入文件,python关闭文件,python读文件,python清空文件内容
摘要:f = open('buffer.py','w+')#打开文件,如果没有该文件则新建文件 f.write(data)#写入文件 f.close()#关闭文件 file1 = open('/usr/share/openstack-dashboard/openstack_dashboard/dashbo 阅读全文
posted @ 2021-09-06 19:04 一杯明月 阅读(193) 评论(0) 推荐(0) 编辑
python写txt-把矩阵数据写进txt文件
摘要:参考:https://blog.csdn.net/qq_38497266/article/details/88871197 dets = np.array([[1,2],[3,4]]) np.savetxt("E:\workspace\dets.txt", dets,fmt='%f',delimit 阅读全文
posted @ 2021-09-06 12:05 一杯明月 阅读(2095) 评论(0) 推荐(0) 编辑
python计时
摘要:来源:https://zhuanlan.zhihu.com/p/110005305 2.使用time.clock() Python time clock() 函数以浮点数计算的秒数返回当前的CPU时间。用来衡量不同程序的耗时,比time.time()更有用。 这个需要注意,在不同的系统上含义不同。在 阅读全文
posted @ 2021-09-06 10:13 一杯明月 阅读(4391) 评论(0) 推荐(0) 编辑
tf.layers.batch_normalization
摘要:来源:https://zhuanlan.zhihu.com/p/82354021 Batch Normalization (BN) 的定义 批归一化就是让一组数据的均值变为0,标准差变为1. 给定 维向量 ,在每个特征上(即针对每一个维度而言)独立地减均值、除以标准差 深度学习中,以 batch 为 阅读全文
posted @ 2021-08-06 22:03 一杯明月 阅读(1112) 评论(0) 推荐(0) 编辑
tf.layers.dense
摘要:https://stackoverflow.com/questions/45693020/is-tf-layers-dense-a-single-layer tf.layers.dense is only one layer with a amount of nodes. You can check 阅读全文
posted @ 2021-08-06 21:29 一杯明月 阅读(556) 评论(0) 推荐(0) 编辑
前向计算
摘要:前向算法的作用是计算输入层结点对隐藏层结点的影响,也就是说,把网络正向的走一遍:输入层—->隐藏层—->输出层计算每个结点对其下一层结点的影响。 是一个简单的加权求和。 这里稍微说一下,偏置项和权重项的作用是类似的,不同之处在于权重项一般以乘法的形式体现,而偏置项以加法的形式体现。 阅读全文
posted @ 2021-08-06 19:41 一杯明月 阅读(448) 评论(0) 推荐(0) 编辑
Iterables,Generators,Yield
摘要:https://stackoverflow.com/questions/231767/what-does-the-yield-keyword-do?page=1&tab=votes#tab-top To understand what yield does, you must understand 阅读全文
posted @ 2021-08-04 19:41 一杯明月 阅读(37) 评论(0) 推荐(0) 编辑
Python之.all()和.any()函数
摘要:Python有很多很有用的内建函数,今天就讲all()和any()这两个函数:这两个函数的参数都是iterable,也就是为list或者tuple all(iterable): >>> help(all) Help on built-in function all in module __built 阅读全文
posted @ 2021-08-03 14:16 一杯明月 阅读(1261) 评论(0) 推荐(0) 编辑
Python位运算符>>和<<
摘要:1 Python位运算符有如下几种 &:按位与:两位都为1,结果为1,否则为0 |:按位或:只要有一位为1,结果就为1 ^:按位异或:两对应的二进位相异时,结果为1 ~: 按位取反,即把1变为0,把0变为1,相当于(-x-1) <<:左移动运算符:运算数的各二进位全部左移若干位,由 << 右边的数字 阅读全文
posted @ 2021-07-31 23:09 一杯明月 阅读(3912) 评论(0) 推荐(0) 编辑
对python数组进行引用
摘要:假如a是一个python的二维数组,则引用第一行第二列的数值的方法是: a[0,1] 阅读全文
posted @ 2021-07-19 16:35 一杯明月 阅读(581) 评论(0) 推荐(0) 编辑
python数组转列表
摘要:>>> import numpy as np >>> a = np.array([[1,2],[3,4]]) >>> b=a.tolist() >>> b [[1, 2], [3, 4]] 阅读全文
posted @ 2021-07-18 11:59 一杯明月 阅读(363) 评论(0) 推荐(0) 编辑
python检查文件是否为空
摘要:import os os.path.getsize(fullpathhere) > 0 >>> import os >>> os.stat("file").st_size == 0 True 阅读全文
posted @ 2021-07-16 09:56 一杯明月 阅读(400) 评论(0) 推荐(0) 编辑
python程序运行完毕发送邮件提醒
摘要:python 发送邮件需要使用 smtplib email 这两个官方库。 import smtplib from email.mime.text import MIMEText from email.header import Header 1、发送普通的邮件 实现步骤: 第一步:创建一个 SMT 阅读全文
posted @ 2021-07-06 18:31 一杯明月 阅读(638) 评论(0) 推荐(0) 编辑
python在运行的时候暂停
摘要:在循环里面加上一个判断就行了,然后在print(pause")这一句打个断点,之后调试运行即可。 for i, data_label_filename in enumerate(data_label_files): print(data_label_filename) if data_label_f 阅读全文
posted @ 2021-07-03 13:58 一杯明月 阅读(1078) 评论(0) 推荐(0) 编辑
Python xrange与range的区别返回的结果不一样
摘要:http://www.nowamagic.net/academy/detail/1302446 range 前面小节已经说明了,range([start,] stop[, step]),根据start与stop指定的范围以及step设定的步长,生成一个序列。 比如: 1 >>> range(5) 2 阅读全文
posted @ 2021-06-25 21:29 一杯明月 阅读(95) 评论(0) 推荐(0) 编辑
python查询数据类型
摘要:用type(...)函数。 例如: 输入是: data_label[1000,-1]输出是: 2.0输入是: type(data_label[1000,-1])输出是: : numpy.float64 输入是: a123=data_label[1000,-1]输入是: a123输出是: 2.0 输入 阅读全文
posted @ 2021-06-24 15:13 一杯明月 阅读(625) 评论(0) 推荐(0) 编辑
python判断数组中是否有重复元素
摘要:判断len(set(nums))是否等于len(nums)就行了,但是有O(n)的空间复杂度。 li = [0, 1, 2, 3, 3, 4, 6, 4] #创建一个列表 a12=np.array(li) # 把列表转换成数组 set(a12) 输出是: {0, 1, 2, 3, 4, 6} len 阅读全文
posted @ 2021-06-23 10:28 一杯明月 阅读(1770) 评论(0) 推荐(0) 编辑
python构建数组
摘要:来源:https://www.cnblogs.com/dylancao/p/10019528.html 一 直接定义法: 1.直接定义 matrix=[0,1,2,3] 2.间接定义 matrix=[0 for i in range(4)] print(matrix) 二 Numpy方法: Nump 阅读全文
posted @ 2021-06-23 10:13 一杯明月 阅读(1011) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 ··· 12 下一页
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示