摘要: 第a维坐标为b的数据 [:,:,...:b]-共a个 import numpy as np # 3维 a = np.array([[[1,2],[3,4]]]) a[:,:,1] output: array([[2, 4]]) input:a[:,1,:] output: array([[3, 4] 阅读全文
posted @ 2021-12-01 15:01 ArdenWang 阅读(99) 评论(0) 推荐(0) 编辑
摘要: !/opt/bin/nvidia-smi import tensorflow as tf tf.test.gpu_device_name() git-clone !git clone https://github.com/wxs/keras-mnist-tutorial.git 下载数据 !wget 阅读全文
posted @ 2021-10-02 09:42 ArdenWang 阅读(2089) 评论(0) 推荐(0) 编辑
摘要: >>> >>> a = np.array([[1,2,3],[4,5,6]]) >>> np.size(a) 6 >>> np.size(a,1) 3 >>> np.size(a,0) 2 1 如果传入的参数只有一个,则返回矩阵的元素个数 如果传入的第二个参数是0,则返回矩阵的行数 如果传入的第二个 阅读全文
posted @ 2021-09-30 16:09 ArdenWang 阅读(245) 评论(0) 推荐(0) 编辑
摘要: np.argwhere( a ) Find the indices of array elements that are non-zero, grouped by element. 返回非0的数组元组的索引,其中a是要索引数组的条件。 返回数组中所有大于1的数字的索引值。 来源:https://bl 阅读全文
posted @ 2021-09-30 16:03 ArdenWang 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 采用python中set()的概念,通过遍历原始文档中的元素,并将其添加到set()中,然后根据set()的性质来判断新的元素是否要被添加到新的文档中去。最终生成的新的文档即满足所需。 #coding:utf-8 readDir = "./original_file.txt" writeDir = 阅读全文
posted @ 2021-09-29 15:51 ArdenWang 阅读(537) 评论(0) 推荐(0) 编辑
摘要: 在Python中,字符串是不可变类型,即无法直接修改字符串的某一位字符。 直接修改会报错:'str' object does not support item assignment 因此改变一个字符串的元素需要新建一个新的字符串。 常见的修改方法有以下4种。 方法1:将字符串转换成列表后修改值,然后 阅读全文
posted @ 2021-09-29 14:08 ArdenWang 阅读(4750) 评论(0) 推荐(1) 编辑
摘要: 1.本文只对一些细节点做补充,大体的步骤就不详述了 2.保存模型 ① 首先我使用的是tensorflow-gpu 1.4.0 ② 这个版本生成的ckpt文件是这样的: 其中.meta存放的是网络模型和所有的变量; .index 和.data一起存放变量数据 -0 -500表示checkpoint点 阅读全文
posted @ 2021-09-28 22:11 ArdenWang 阅读(332) 评论(0) 推荐(0) 编辑
摘要: #!/usr/bin/env python -- coding: utf-8 -- if name == 'main': list = ['html', 'js', 'css', 'python'] # 方法1 print '遍历列表方法1:' for i in list: print ("序号:% 阅读全文
posted @ 2021-09-28 10:53 ArdenWang 阅读(293) 评论(0) 推荐(0) 编辑
摘要: ```python # -*- coding: utf-8 -*-'''遇到文中的空格就换行'''def delblankline(infile, outfile): infopen = open(infile, 'r',encoding="utf-8") outfopen = open(outfi 阅读全文
posted @ 2021-09-28 09:17 ArdenWang 阅读(840) 评论(0) 推荐(0) 编辑
摘要: 今天使用python处理一个txt文件的时候,遇到几个特殊字符:\ufeff、\xa0、\u3000,记录一下处理方法 with open(file_path, mode='r') as f: s = f.read() \ufeff 字节顺序标记 去掉\ufeff,只需改一下编码就行,把UTF-8编 阅读全文
posted @ 2021-09-28 09:05 ArdenWang 阅读(4877) 评论(0) 推荐(0) 编辑