본문 바로가기
AI

TensorFlow란 무엇인가

by Awesome-SH 2021. 3. 16.

 

이 포스팅은 사내에서 신규 AI 교육을 듣기 전,

사전 스터디를 하며 정리한 포스팅입니다.

 

TensorFlow

ML (Machine Learning) 모델을 개발하고 학습시키는데 도움이 되는 오픈소스 라이브러리이며

언어는 파이썬(Python)을 지원한다. ( JS 버전도 제공 )

데이터 플로우 그래프(Data Flow Graph)를 사용해서 수치계산을 (Numerical Computation)을 한다고도 할 수 있다.


데이터 플로우 그래프 (Data Flow Graph)

노드(Node)와 간선(Edge)로 연결되어 있는 그래프

노드 : 하나의 오퍼레이션 개념

엣지 : 데이터 또는 데이터 배열 ( 즉, Tensors )


Installing TensorFlow

  • Linux
    • pip install —upgrade tensorflow (option, -gpu)
    • GPU를 사용하고자 한다면 -gpu 옵션을 추가해주면 됨

TensorFlow Mechanics

1. Build graph using TensorFlow Operations

2. Feed data and Run graph (operation)

3. Update variables in the graph (and Return values)

 

TensorFlow Check Version

$ python3
>> import tensorflow as tf

# 텐서플로우 버전 확인
>> tf.__version__

 

TensorFlow Print Hello World

hello = tf.constant("Hello, Tensorflow!")

sess = tf.Session()

print(sess.run(hello))

Tensorflow 에서 출력하기 위해서는  tf.Session()  을 통해 출력함

 

Computational Graph

node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0)
node3 = tf.add(node1, node2)  # node1 + node2로 표현할 수 있음

 

Placeholder

a = tf.placeholder(tf.float32) # Type을 지정해놓음
b = tf.placeholder(tf.float32)

adder_node = a + b

print(sess.run(adder_node, feed_dict={a: 3, b: 4.5}))
# 위 처럼 타입만 지정해놓은 Placeholder에 Feed_dict을 이용해서 실행단에서 값을 넣어줄 수 있음

 

Tensor Ranks, Shapes, Types

Rank는 현재 텐서가 몇 차원인지 구분하기 위한 것

Shape는 값이 몇 개가 들어가있는지

Type은 Python Type

'AI' 카테고리의 다른 글

🚀 Claude Code /compact 고급 활용 가이드  (1) 2025.08.08
Claude 토큰 절약 완전 가이드 💰  (0) 2025.08.07

댓글