본문 바로가기
코딩/파이썬

텐서플로우 set_random_seed 함수 에러, AttributeError: module 'tensorflow' has no attribute 'set_random_seed' 해결 방법

by yenua 2024. 3. 28.
반응형
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-4-3cc2ef11f336> in <cell line: 29>()
     27 np.random.seed(RANDOM_SEED)
     28 rn.seed(RANDOM_SEED)
---> 29 tf.set_random_seed(RANDOM_SEED)

AttributeError: module 'tensorflow' has no attribute 'set_random_seed'

해당 오류는 tensorflow 버전에 따라 지원하는 함수 명이 달라 발생하는 문제로, 'tf.set_random.set_seed(RANDOM_SEED)'으로 변경하여 해결할 수 있다.

 

반대로, 예전 버전의 텐서플로우를 사용한다면 tf.set_random_seed(RANDOM_SEED)를 사용하면 된다.

 

참고: https://aeir.tistory.com/entry/%ED%85%90%EC%84%9C%ED%94%8C%EB%A1%9C-%EC%97%90%EB%9F%AC-AttributeError-module-tensorflow-has-no-attribute-setrandomseed

반응형