티스토리 뷰
ERROR/SQL
[python]AttributeError: 'Tensor' object has no attribute 'numpy'
onlyun 2022. 6. 17. 15:32
파이썬에서
TensorFlow 2 하다가...
a = tf.constant(10)
b = tf.constant(20)
c = a + b
d = (a+b).numpy() #<-여기서 에러떴음
print(type(c))
print(c)
print(type(d), d)
d_numpy_to_tensor = tf.convert_to_tensor(d)
print(type(d_numpy_to_tensor))
print(d_numpy_to_tensor)
AttributeError Traceback (most recent call last) Input In [44], in <cell line: 5>() 2 b = tf.constant(20) 4 c = a + b ----> 5 d = (a+b).numpy() 7 print(type(c)) 8 print(c) File ~\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py:446, in Tensor.__getattr__(self, name) 437 if name in {"T", "astype", "ravel", "transpose", "reshape", "clip", "size", 438 "tolist", "data"}: 439 # TODO(wangpeng): Export the enable_numpy_behavior knob 440 raise AttributeError( 441 f"{type(self).__name__} object has no attribute '{name}'. " + """ 442 If you are looking for numpy-related methods, please run the following: 443 from tensorflow.python.ops.numpy_ops import np_config 444 np_config.enable_numpy_behavior() 445 """) --> 446 self.__getattribute__(name) AttributeError: 'Tensor' object has no attribute 'numpy' |
더보기
AttributeError Traceback (most recent call last)
Input In [44], in <cell line: 5>()
2 b = tf.constant(20)
4 c = a + b
----> 5 d = (a+b).numpy()
7 print(type(c))
8 print(c)
File ~\anaconda3\lib\site-packages\tensorflow\python\framework\ops.py:446, in Tensor.__getattr__(self, name)
437 if name in {"T", "astype", "ravel", "transpose", "reshape", "clip", "size",
438 "tolist", "data"}:
439 # TODO(wangpeng): Export the enable_numpy_behavior knob
440 raise AttributeError(
441 f"{type(self).__name__} object has no attribute '{name}'. " + """
442 If you are looking for numpy-related methods, please run the following:
443 from tensorflow.python.ops.numpy_ops import np_config
444 np_config.enable_numpy_behavior()
445 """)
--> 446 self.__getattribute__(name)
AttributeError: 'Tensor' object has no attribute 'numpy'
->
문서 내에서
#Tensorflow 2 설치 후 Tensorflow 2 사용
import tensorflow.compat.v1 as tf1
tf1.disable_v2_behavior() #tensorflow version 2를 사용 안 하겠다.
를 수행? 실행시켰기 때문에 이 문서 내에서는 더이상 Tensorflow2의 것들을 사용할 수 없음.
-> 새로운 문서에서
Tensorfow2를 import하고 안의 속성들을 사용하면 됨.
'ERROR > SQL' 카테고리의 다른 글
[django]AttributeError at /bookmark/module 'bookmark' has no attribute '_default_manager' (0) | 2022.07.04 |
---|---|
[pythons]AttributeError: 'NoneType' object has no attribute 'split' (0) | 2022.06.30 |
[python]The _imagingft C module is not installed (0) | 2022.06.14 |
Please use the NLTK Downloader to obtain the resource: (0) | 2022.06.14 |
[CredentialHelperSelector]깃허브에 올리려고 할 때, (0) | 2022.04.28 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- scanner
- BAEKJOON
- html pre
- 스크립태그
- selcetor
- JavaScript
- input type 종류
- Java
- html
- CascadingStyleSheet
- 변수
- border-spacing
- 외부구성요소
- html layout
- 기본선택자
- text formatting
- improt
- css
- html atrribute
- typeof
- ScriptTag
- html input type
- html base tag
- html a tag
- caption-side
- empty-cell
- 미디어 태그
- initialized
- 입력양식
- A%B
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
글 보관함