프로그램 사용/yolo_tensorflow

텐서플로우 v1 을 v2로 마이그레이션은 실패 -_-

구차니 2024. 1. 10. 11:30

아래의 스크립트를 이용하여 변환이 가능하다는데, 정작 변환하고 실행하려고 하면 안되고(import는 안건드리니)

$ tf_upgrade_v2 --infile tensorfoo.py --outfile tensorfoo-upgraded.py

[링크 : https://www.tensorflow.org/guide/upgrade?hl=ko]

 

차라리 아래처럼 import tensorflow as tf를 compat.v1 으로 바꾸어주고, v2 를 끄면 구버전이 실행된다.

import tensorflow.compat.v1 as tf
tf.disable_v2_behavior()

[링크 : https://www.tensorflow.org/guide/migrate?hl=ko]

 

 

--------------------------------

돌려보니 먼가 나오긴 한데

INFO line 7:16: Renamed 'tf.random_uniform' to 'tf.random.uniform'
INFO line 8:16: Renamed 'tf.random_uniform' to 'tf.random.uniform'
INFO line 11:4: Renamed 'tf.placeholder' to 'tf.compat.v1.placeholder'
INFO line 12:4: Renamed 'tf.placeholder' to 'tf.compat.v1.placeholder'
INFO line 25:12: Renamed 'tf.train.GradientDescentOptimizer' to 'tf.compat.v1.train.GradientDescentOptimizer'
INFO line 30:5: Renamed 'tf.Session' to 'tf.compat.v1.Session'
INFO line 31:13: Renamed 'tf.global_variables_initializer' to 'tf.compat.v1.global_variables_initializer'
TensorFlow 2.0 Upgrade Script
-----------------------------
Converted 1 files

 

잘 돈다는 보장은 없다 -_-

 

요런 에러가 뜨면

RuntimeError: tf.placeholder() is not compatible with eager execution.

 

아래줄 추가해주면 되는데

tf.compat.v1.disable_eager_execution()

[링크 : https://luvstudy.tistory.com/122]

 

정작 텐서 곱할 때, 에러가 발생한다.

RuntimeError: resource: Attempting to capture an EagerTensor without building a function.

 

요건 막혀서 모르겠네 -_-

함수를 만들지 않고 eagertensor를 capture 하기 시도해서 에러가 발생한거라면..

함수(building a function)를 만들면 되는건가?