[代码笔记]python函数方法笔记
tensorboard
1 | from torch.utils.tensorboard import SummaryWrite |
启动tensorboard:控制台中输入tensorboard --logdir=logs # logs为路径
多维数组中根据一维数组寻找其下标(numpy)
给一个多维数组nums,返回里面的一维数组target的下标index。1
2
3
4
5
6
7
8
9
10
11import numpy as np
nums = np.array([[1, 2, 3],
[1, 3, 5],
[1, 5, 6]])
target = [1, 3, 5]
for index, num in enumerate(nums):
if (target == num).all():
print(index, num)
out:1
1 [1 3 5]