Difference between ( ) and ( )
>>> y=(1,6) >>> y tensor([1., 2., 3., 4., 5., 6.]) >>> torch.float32 >>> z=(1,6) >>> z tensor([1, 2, 3, 4, 5]) >>> torch.int64
what one learns from one's mistakes
-
(start=1, end=6)
The result will contain theend
rather -
(start=1, end=6)
The result does not contain theend
。 - Both created
tensor
The type of the is also different.
Reference:
Pytorch ()&()
(start=1, end=6)
The result is that it will contain end, and the type of the created tensor is float32.
(start=1, end=6)
The result does not contain end, and the tensor created is of type int64.
coding
>>> y=(1,6) >>> y tensor([1., 2., 3., 4., 5., 6.]) >>> torch.float32 >>> z=(1,6) >>> z tensor([1, 2, 3, 4, 5]) >>> torch.int64
pytorch
appliance
>>> (5) tensor([ 0, 1, 2, 3, 4])
API
(start=0, end, step=1, out=None, dtype=None, layout=, device=None, requires_grad=False) → Tensor
parameters | descriptive |
---|---|
start (Number) | |
end (Number) | |
step (Number) | |
out (Tensor, optional) | |
dtype (, optional) | |
layout (, optional) | |
device (, optional) | |
requires_grad (bool, optional) |
summarize
The above is a personal experience, I hope it can give you a reference, and I hope you can support me more.