모두를 위한 딥러닝 강의 시즌1을 듣고 복습한 내용입니다.
시험 점수 예측
Quiz 1 ( X1 ) | Quiz 2 ( X2 ) | Midterm 1 ( X3 ) | Final ( Y ) |
73 | 80 | 75 | 152 |
93 | 88 | 93 | 185 |
89 | 91 | 90 | 180 |
96 | 98 | 100 | 196 |
[instance 수, var 수] * [ ? = var수 , ? = Y ] = [instance 수, Y]
- [n, 3] * [ ? = 3 , ? = 2 ] = [n, 2]
텐서플로우 코드 (버전 2.0 이상)
import tensorflow as tf
import numpy as np
x_data = [[73., 80., 75.],
[93., 88., 93.],
[89., 91., 90.],
[96., 98., 100.],
[73., 66., 70.]]
y_data = [[152.],
[185.],
[180.],
[196.],
[142.]]
tf.model = tf.keras.Sequential()
tf.model.add(tf.keras.layers.Dense(units=1, input_dim=3)) # input_dim=3 gives multi-variable regression
tf.model.add(tf.keras.layers.Activation('linear')) # this line can be omitted, as linear activation is default
# advanced reading https://towardsdatascience.com/activation-functions-neural-networks-1cbd9f8d91d6
tf.model.compile(loss='mse', optimizer=tf.keras.optimizers.SGD(lr=1e-5))
tf.model.summary()
history = tf.model.fit(x_data, y_data, epochs=100)
y_predict = tf.model.predict(np.array([[72., 93., 90.]]))
print(y_predict)
'딥러닝, 머신러닝 > 모두를 위한 딥러닝 강의 복습' 카테고리의 다른 글
Logistic Classification, Logistic Regression의 cost 함수 (0) | 2022.01.05 |
---|---|
TensorFlow로 파일에서 데이터 읽어오기 (0) | 2022.01.04 |
Linear Regression의 cost 최소화 알고리즘의 원리 (0) | 2022.01.04 |
Linear Regression (0) | 2022.01.04 |
기본적인 Machine Learning 의 용어와 개념 설명 (0) | 2022.01.04 |