Tensorflow์ ๊ธฐ๋ณธ์ ์ธ Operation์ ๋ํด ์์๋ณด์๋ค.
Tensorflow๋ data flow graphs๋ฅผ ์ฌ์ฉํด numerical ํ ๊ณ์ฐ์ ํ๋ Library์ด๋ค.
Edge ์ ๋์๋ค๋๋ Data๋ค์ Tense๋ผ๊ณ ํ๋๋ฐ, ๊ทธ๋ค์ ๋์๋ค๋, ์ฆ ํ๋ฆ์ Flow๋ผ๊ณ ํ๊ณ , ๊ทธ๊ณณ์์ ๋์จ ์ด๋ฆ์ด Tensorflow์ด๋ค.
๋ณธ๊ฒฉ์ ์ผ๋ก Tensorflow ์ฝ๋๋ฅผ ์คํํด๋ณด๋ ค๊ณ ํ๋๋ฐ, ๋ ๋ค์ ๋ฒ์ ์ด์ ์ ๋ฌธ์ ๊ฐ ์๊ฒผ๋ค.
"AttributeError : module 'tensorflow' has no attribute 'Session'"
tensorflow version 1๋ก ์์ฑ๋ ์ฝ๋์ด๊ธฐ ๋๋ฌธ์ Session ํจ์๋ฅผ ์ฌ์ฉํ๊ณ , version 2์์๋ถํฐ๋ Session์ด ์ ์ฉ๋์ง ์๊ธฐ ๋๋ฌธ์ ๋ค๋ฅธ ํจ์๊ฐ ํ์ํ๋ค.
๊ฐ๋จํ๊ฒ tf.print๋ฅผ ์จ๋ฒ๋ฆฌ๋ฉด ๋๋ค. ์ญ์ ๋ฒ์ ์ ๊ทธ๋ ์ด๋๋ ์ ์ ๊ฐ ํธ์ํ ๋ฐฉํฅ์ผ๋ก ๊ฐ๋ค๋ ํ์ ์ ๊ฐ๊ณ ์์ด์ผ ํ๋ค.
Tensorflow๋ ๊ทธ๋ํ๋ฅผ ์ฐ์ ๋น๋ํ๊ณ , ๊ทธ๋ํ๋ฅผ ์คํ์ํค๊ณ , ๊ทธ ๊ฐ์ ๋ฆฌํด์ํค๋ ํ์์ด๋ค.
Version 2์์๋ Session() ํจ์๋ฅผ ํตํด ๊ทธ๋ํ๋ฅผ ์คํ์ํค๋ ๊ณผ์ ์ด ์๋ต๋์๋ค๊ณ ๋ณผ ์ ์๋ค.
placeholder ์์๋ ๋น์ทํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋๋ฐ,
"AttributeError : module 'tensorflow' has no attribute 'placeholder'"
์ฌ์ค ์ด๊ฒ ์ ์์ ์๋๋ค. ์ ์ด์ tf.placeholder ํจ์๋ ๋ณ์๋ฅผ ์ ์ธํ ๋ ์์๋ก ์ ์ธํ๋ ๊ฒ์ด ์๋๋ผ, ๋์ค์ ๊ฐ์ ๋ฃ์ด์ค ๊ณต๊ฐ์ ๋ง๋๋ ๊ฒ์ด๋ค.
Tensorflow 2.0 ์์๋ถํฐ๋ @tf.function ํจ์๋ฅผ ํตํด์ placeholer์ ์ญํ ์ ๋์ฒดํ๋ค๊ณ ํ๋ค.
tf.Variable ์์ 3.0, 4.5 ๊ฐ์ integer ๊ฐ์ ๋ฃ์์ ๋
๋ค์๊ณผ ๊ฐ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค.
"Input 'y' of 'AddV2' Op has type int32 that does not match type float32 of argument 'x'."
tf.Variable ํจ์ ์์ ์ ์ ๊ฐ๋ง ๋ฃ๊ณ , ์ค์ ๊ฐ์ ๋ฃ์์ง ์๋ ๊ฒ์ธ์ง ์กฐ๊ธ ๋ ํ๋ณผ ํ์๊ฐ ์์ด๋ณด์ธ๋ค.
Tensor Ranks. Shapes. and Types
Scalar -> 0์ฐจ์ : rank = 0
Vector -> 1์ฐจ์ : rank = 1
Matrix -> 2์ฐจ์ : rank = 2
3- Tensor -> 3์ฐจ์ : rank = 3
n - Tensor -> n ์ฐจ์ : rank = n
tense ๋ array์ ๊ฐ๋ ์ด๋ค.
element์ ๋ช ๊ฐ์ฉ ๋ค์ด์๋์ง๋ฅผ shape์ด๋ผ๊ณ ํํํ๋ค.
[D0 , D1] ์ D0 ์ฉ D1 ๊ฐ๊ฐ ์๋ shape์ ๋ํ๋ธ๋ค. ์ฐจ์์ด ๋ค์ด๋๋ฉด D์ ๊ฐ์๊ฐ ๋์ด๋๊ฒ ๋๋ค.
type ๊ฐ์ ๊ฒฝ์ฐ์๋, ๋๋ถ๋ถ์ ๊ฒฝ์ฐ float32์ int32๋ฅผ ๋ง์ด ์ฌ์ฉํ๋ค.
'DataScience > Machine Learning Basic' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Tensorflow Linear Regression Implementation (1) | 2022.01.26 |
---|---|
Linear Regression (0) | 2022.01.25 |
Tensorflow in Pycharm ๊ทธ๋ฆฌ๊ณ Google Colab (0) | 2022.01.21 |
Tensorflow ์ ๋จธ์ ๋ฌ๋ (0) | 2022.01.21 |
์ธ๊ณต์ง๋ฅ , ๋จธ์ ๋ฌ๋ ๊ทธ๋ฆฌ๊ณ ๋ฅ๋ฌ๋ (0) | 2022.01.21 |