Goku Coding Experience
Monday, 21 October 2019
torch - convert a tensor to numpy
Converting a Torch Tensor to a NumPy Array ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
a
=
torch
.
ones
(
5
)
print
(
a
)
tensor([1., 1., 1., 1., 1.])
b
=
a
.
numpy
()
print
(
b
)
[1. 1. 1. 1. 1.]
See how the numpy array changed in value.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment