E:\Eprogramfiles\Anaconda3\lib\site-packages\torch\_tensor.py in __array__(self, dtype)
676 return handle_torch_function(Tensor.__array__, (self,), self, dtype=dtype)
677 if dtype is None:
--> 678 return self.numpy()
679 else:
680 return self.numpy().astype(dtype, copy=False)
RuntimeError: Numpy is not available
====================
E:\Eprogramfiles\Anaconda3\Scripts>pip show tensorflow
Name: tensorflow
Version: 2.4.1
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: e:\eprogramfiles\anaconda3\lib\site-packages
Requires: grpcio, absl-py, gast, h5py, six, opt-einsum, wheel, flatbuffers, wrapt, google-pasta, astunparse, protobuf, termcolor, numpy, keras-preprocessing, typing-extensions, tensorboard, tensorflow-estimator
Required-by:
E:\Eprogramfiles\Anaconda3\Scripts>pip show tensorflow-gpu
WARNING: Package(s) not found: tensorflow-gpu
E:\Eprogramfiles\Anaconda3\Scripts>pip show tensorflow-cpu
WARNING: Package(s) not found: tensorflow-cpu
E:\Eprogramfiles\Anaconda3\Scripts>
====================================
def __array__(self, dtype=None):
if has_torch_function_unary(self):
return handle_torch_function(Tensor.__array__, (self,), self, dtype=dtype)
if dtype is None:
return self.numpy()
else:
return self.numpy().astype(dtype, copy=False)
====================================
x = torch.randn(1, requires_grad=True)
x.numpy()
# > RuntimeError: Can't call numpy() on Tensor that requires grad. Use tensor.detach().numpy() instead.
print(x.detach().numpy())
# > array([-0.13592759], dtype=float32)
====================================