커뮤니티
Python/TensorFlow
제목:    tensorflow Keras vs code사용 tips
  516   김윤중
  • tensorflow
    • import os
      os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'  #  any {'0', '1', '2'} tf의 메세지 출력 제어 클수록 많이 출력
      from tensorflow.python.client import device_lib# GPU 수동 활성화
      device_lib.list_local_devices()                         # GPU 활성화
      import tensorflow as tf
      #또는 #TF2.0이상에서 tf 1.x 실행시
      #import tensorflow.compat.v1 as tf                 # tf 2.0이상에서 F 1.x 실행시
      #tf.disable_v2_behavor()
      gpus = tf.config.experimental.list_physical_devices('GPU')
      print(f'GPUs {gpus}')                                   # 활성화된 GPU 정보
  • vs code 모듈 참조
    • import sys
      from pathlib import Path
      sys.path[0] = str(Path(sys.path[0]).parent)
    • folder 구조
      • yolov3
        • utils.py
      • tools
        • a.py 의 내용
          from pathlib import Path
          sys.path[0] = str(Path(sys.path[0]).parent)
          from yolov3.utils imprt Print
          Print('log.txt')
          Print('message')