Tensorflow
#Tensorflow TensorFlow๋ ๊ตฌ๊ธ์์ ์์น์ฐ์ฐ์ ์ํด ๋ง๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ด๋ค. ๊ธฐ๋ณธ ๊ฐ๋ node์ edge๋ก ๊ตฌ์ฑ๋ graph๋ฅผ ์ด์ฉํด ์์น ์ฐ์ฐ์ ์ํํ๋ค. node๋ค์ ํน์ ํ ๋ฐ์ดํฐ๊ฐ ๋ค์ด์ค๋ฉด ์ฐ์ฐ์ ์ํํ๊ฑฐ๋, ํํ๋ฅผ ๋ณ๊ฒฝํ๊ฑฐ๋, ๊ฒฐ๊ณผ๋ฅผ ์ถ๋ ฅํ๋ ์ญํ ์ ํ๋ค. edge๋ ํ์ต๋ฐ์ดํฐ๊ฐ ์ ์ฅ๋๋ ๋ค์ฐจ์ ๋ฐฐ์ด์ด๋ค. edge๋ node์์ ๊ณ์ฐ๋ ๋ฐ์ดํฐ๋ฅผ ๋ค์ node๋ก ์ด๋์ํจ๋ค. edge๋ ๋ฐฉํฅ์ฑ์ด ์์ผ๋ฉฐ(directed), tensor๋ผ ๋ถ๋ฆฐ๋ค. archive.ics.uci.edu/ml ์์ ํ์ต์ฉ ๋ฐ์ดํฐ๋ฅผ ๋ฐ์ ์ฌ์ฉํ ์ ์๋ค. ์ค์น python๊ณผ pip๋ฅผ ์ค์นํ๋ค. pip install tensorflow ๋ช ๋ น์ ์ํํ๋ค. window์์ โclient_load_reporting_filter.hโ ํ์ผ์ ์ฐพ์ง ๋ชปํด ์ค์น๋ฅผ ๋ชปํ๋ค๋ฉด, path ๊ฒฝ๋ก๊ฐ ๋๋ฌด ๊ธธ์ด์ ๋ฐ์ํ๋ ์ค๋ฅ์ด๋ค. ์คํ์์ regedit์ ์คํํ๊ณ , โHKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystemโ ๋ ์ง์คํธ๋ฆฌ๋ฅผ ์ฐพ์ ๊ฐ์ 1๋ก ์ธํ ํด์ค๋ค. ์ฐ๊ด ๋ชจ๋ ํจ๊ป ์ฐ๋ฉด ํจ์จ์ด ์ข์ ๋ชจ๋๋ค matplotlib numpy data = np.loadtxt(FILE_NAME, delimiter=',') : ,๋ฅผ ๊ธฐ์ค์ผ๋ก ๋ฐ์ดํฐ๋ฅผ ๋๋๋ csv ํ์ผ์ ์ฝ์ด๋ค์. ์ซ์ ๋ฐ์ดํฐ๋ฅผ ์ฝ์ ๋ ์ฌ์ฉ keras (tensorflow ์ค์น์ ์๋์ฑ์น๋๋ค) y_encoded = to_categorical(y_data) : y_data ๋ฅผ one-hot-encoding ํ๋ ํจ์ (tensorflow.keras.utils.to_categorical) pandas df = pd.read_csv(FILE_NAME) : csv ํ์ผ์ ์ฝ์ด์ dataframe์ ๊ตฌ์ฑํ๋ค. ์ซ์ ๋ฐ ๋ฌธ์์ด ๋ฐ์ดํฐ๋ฅผ ์ฝ์ ๋ ์ฌ์ฉ ๊ฐ๋ฅ sklearn ๋ฐ์ดํฐ ์ ์ฒ๋ฆฌ e = sklearn.preprocessing.LabelEncoder() e.fit(data) # data ์ ๋ค์ด์๋ ๊ฐ ์ค uniqueํ ๊ฐ์ ๋ฝ์(์ค๋ณต ์ ๊ฑฐ) ํน์ string์ ๋ฒํธ๋ฅผ ๋งค๊ธฐ๋(indexing) ํจ์ data = e.transform(data) # indexing ๋ ์ ๋ณด๋ฅผ ๋ฐํ์ผ๋ก ์ค์ data๊ฐ์ index๋ก ์นํ ๊ธฐ๋ณธ ๋ฌธ๋ฒ ์์ ์ ์ธ val = tf.constant(value, dtype=None, shape=None, name='Conts', verify_shape=False) value = ๊ฐ dtype : ๋ฐ์ดํฐ ํ์ , ex) โtf.float32โ, โtf.float64โ, โtf.int8โ float(32, 64), int(8, 16, 64),uint(8, 16), string, bool, complex(64, 128 : ๋ณต์์) shape : ์ฐจ์, value ํํ์ ๋ฐ๋ผ ์๋์ผ๋ก ์ค์ ๋จ, ex) โ[3,3]โ name : ์์์ ์ด๋ฆ verify_shape : tensor์ shape๋ฅผ ๋ฐ๊ฟ์ ์๋์ง ์ฌ๋ถ ๋ฐฐ์ด ์์ฑ arr = tf.range(5) output : tf.Tensor : shape(5,), dtype=int32, numpy=([0, 1, 2, 3, 4], dtype=int32) ...