摘要: import numpy as np a = np.ones(5) b = torch.from_numpy(a) np.add(a, 1, out=a) print(a) print(b) print(a) a = torch.ones(5) print(a)b = a.numpy()print( 阅读全文
posted @ 2021-10-14 19:33 呦呦南山 阅读(215) 评论(0) 推荐(0) 编辑
摘要: 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) 编辑