PyTorch torch.frombuffer function
PyTorch torch reference manual
torch.frombuffer A function in PyTorch for creating a 1D tensor from a buffer.
Function definition
torch.frombuffer(buffer, dtype, count, offset)
Usage examples
Example
import
torch
import
array
Create from an array
arr
=
array
.
array
(
'i'
,
[
1
,
2
,
3
,
4
,
5
]
)
x
=
torch.
frombuffer
(
arr
,
dtype
=
torch.
int32
)
(
x
)