None作为ndarray或tensor的索引
None作为ndarray或tensor的索引作用是增加维度,与 pytorch中的 torch.unsqueeze() 或 tensorflow 中的tf.expand_dims() 作用相同
例子:
In [5]: t=torch.from_numpy(np.arange(12).reshape(3,4))
In [6]: t
Out[6]:
tensor([[ 0, 1, 2, 3]...
原创
2020-04-07 12:01:00 ·
2015 阅读 ·
0 评论