摘要: bool转化为01 array = np.array([True, False])array.astype(int) 01-> bool b = np.array([1,0,1,0,0])b.astype(bool)`` 阅读全文
posted @ 2021-10-14 19:31 呦呦南山 阅读(208) 评论(0) 推荐(0) 编辑
摘要: torch.clamp(input, min, max, out=None) 将输入input张量每个元素的范围限制到区间 [min,max],返回结果到一个新张量。 input (Tensor) – 输入张量min (Number) – 限制范围下限max (Number) – 限制范围上限out 阅读全文
posted @ 2021-10-14 19:29 呦呦南山 阅读(891) 评论(0) 推荐(0) 编辑
摘要: isinstance() 函数来判断一个对象是否是一个已知的类型,类似 type()。 isinstance() 与 type() 区别: type() 不会认为子类是一种父类类型,不考虑继承关系。 isinstance() 会认为子类是一种父类类型,考虑继承关系。 如果要判断两个类型是否相同推荐使 阅读全文
posted @ 2021-10-14 19:28 呦呦南山 阅读(1363) 评论(0) 推荐(0) 编辑
摘要: torch.cuda.is_available()cuda是否可用; torch.cuda.device_count()返回gpu数量; torch.cuda.get_device_name(0)返回gpu名字,设备索引默认从0开始; torch.cuda.current_device()返回当前设 阅读全文
posted @ 2021-10-12 15:17 呦呦南山 阅读(547) 评论(0) 推荐(0) 编辑
摘要: 该指令可实时查看gpu使用情况 watch -n1 gpustat 阅读全文
posted @ 2021-10-12 11:54 呦呦南山 阅读(715) 评论(0) 推荐(0) 编辑
摘要: kill命令格式:kill -Signal pidpid是进程号,可以用 ps 命令查出 signal是发送给进程的信号, 默认参数下,kill 发送SIGTERM(15)信号给进程,告诉进程,你需要被关闭,请自行停止运行并退出。kill -9 发送SIGKILL信号给进程,告诉进程,你被终结了,请 阅读全文
posted @ 2021-10-08 16:26 呦呦南山 阅读(601) 评论(0) 推荐(0) 编辑
摘要: (1)np.save()和np.load() #存储数组数据, .npy文件import numpy as np import osos.chdir(r'C:\python数据分析')ar = np.random.rand(5,5)print(ar)np.save('arraytest.npy',a 阅读全文
posted @ 2021-10-08 16:19 呦呦南山 阅读(1624) 评论(0) 推荐(0) 编辑
摘要: (1)list转array np.array(a) (2)array 转list a.tolist() 阅读全文
posted @ 2021-10-08 15:47 呦呦南山 阅读(840) 评论(0) 推荐(0) 编辑
摘要: import numpy as np a = np.random.randint(-5, 5, (1, 10)) c=np.sum(a>=1) #条件为大于等于1 print ("随机数组a : "+str(a)) #输出数组a print ("大于等于1的个数: "+str(c)) #输出满足条件 阅读全文
posted @ 2021-10-08 15:46 呦呦南山 阅读(4677) 评论(0) 推荐(0) 编辑
摘要: 程序本来运行正常,经多次测试,发现出现这个问题,是因为数据集出现错误,应该是保存过程中出现数据损失,重新下载新的数据集再次测试,则可以运行。 阅读全文
posted @ 2021-09-23 12:02 呦呦南山 阅读(2573) 评论(0) 推荐(0) 编辑