JONNY ALOHA
AERO-CHOI's BLOG
JONNY ALOHA
전체 방문자
오늘
어제
  • 분류 전체보기 (35)
    • Learning S.. (29)
      • X-Foil (3)
      • Aerodynami.. (1)
      • Autonomous.. (5)
      • Machine Le.. (6)
      • MATLAB (0)
      • C++ (3)
      • ROS (8)
      • Optimizati.. (3)

블로그 메뉴

  • 홈
  • About Me

인기 글

태그

티스토리

hELLO · Designed By 정상우.
JONNY ALOHA

AERO-CHOI's BLOG

Learning Space/Machine Learning, Deep Learning

[Machine Learning] TensorFlow를 시작하며

2023. 6. 14. 14:47

본 문서는 TensorFlow 2.12.0 을 기준으로 작성하였습니다.

 

import tensorflow as tf

 

1.x와 2.x의 차이점

A. Session과 run의 사라짐

hello = tf.constant("hello, TensorFlow!")

print(hello)

2.0 이전까지는 Session 모듈을 실행해야만 연산이 가능했으나

2.0 이후부터는 Session 없이 선언과 동시에 실행이 되는 형태로 바뀌었다.

 

B. placeholder의 사라짐

2.0 이전에서는 아래와 같이

a = tf.placeholder(tf.float32)
b = tf.placeholder(tf.float32)
add_node = a + b

print(sess.run(add_node, feed_dict={a:3, b:2}))

placeholder 모듈을 이용해서 변수 선언 후 나중에 값을 할당하는 형태를 지원했다.

 

2.0 이후부터는

@tf.function
def add(a, b):
	return a + b
    
A = tf.constant(1)
B = tf.constant(2)

print(add(A, B))

@tf.function을 이용하여 함수를 정의하는 형태로 바뀌었다.

 

Tensor Ranks

# Scalar(magnitude only)
a = 100

# Vector(magnitude and direction)
v = [1.1, 2.2, 3.3]

# Matrix(table of numbers)
m = [[1,2,3], [4,5,6], [7,8,9]]

# 3-Tensor(cube of numbers)
t = [[[2], [4], [6]], [[6], [7], [8]], [[10], [12], [14]

# n-Tensor

Tensor Shapes

# Rank 0 & Dimension number 0-D
[]

# Rank 1 & Dimension number 1-D
[D0]

# Rank 2 & Dimension number 2-D
[D0, D1]

# Rank 3 & Dimension number 3-D
[D0, D1, D2]

# Rank n & Dimension number n-D
[D0, D1, D2, ---, Dn-1]

Tensor Types

# 32 bits floating point
tf.float32

# 64 bits floating point
tf.float64

# 8 bits signed integer
tf.int8

# 16 bits signed integer
tf.int16

# 32 bits signed integer
tf.int32

# 64 bits signed integer
tf.int64

 

728x90
저작자표시 비영리 동일조건 (새창열림)

'Learning Space > Machine Learning, Deep Learning' 카테고리의 다른 글

[Machine Learning] 환경구축(TensorFlow)  (1) 2023.06.14
KNN(K-Nearest Neighbor)  (0) 2023.01.02
머신러닝의 이해  (0) 2023.01.01
환경 설정  (0) 2023.01.01
Linear Models for Regression(선형회귀 모델)  (0) 2022.12.21
    'Learning Space/Machine Learning, Deep Learning' 카테고리의 다른 글
    • [Machine Learning] 환경구축(TensorFlow)
    • KNN(K-Nearest Neighbor)
    • 머신러닝의 이해
    • 환경 설정
    JONNY ALOHA
    JONNY ALOHA

    티스토리툴바