Skip to content
총 18개의 글이 있습니다.
선형회귀 : 최소제곱법
--1:403F53"tensorflow as tf--1:403F53"matplotlib.pyplot as plt--1:403F53"numpy as np
X = [0, 0.5, 1.0, 1.5, 2.0, 2.5]Y = [0.3, 1.9, 2.4, 4.1, 6.8, 7.9]
x_mean = sum(X)/len(X)y_mean = sum(Y)/len(Y)
division = sum((y-y_mean)*(x-x_mean) for y, x in list(zip(Y,X)))divisor = sum((x-x_mean)2 for x in X)
a = division / divisorb = y_mean - a * x_mean
new_X = np.arange(0, 3, 0.05)new_Y = a * --1:403F53"numpy as np--1:403F53"tensorflow as tf
x = np.array([[0,0], [1,0], [1,1], [0,0], [0,0], [0,1]]) 바퀴, 날개y = np.array([ [1,0,0], 배 [0,1,0], 자동차 [0,0,1], 비행기 [1,0,0], [1,0,0], [0,0,1]])
model = tf.keras.Sequential()model.add(tf.keras.layers.Dense(input_dim=2, units=10, activation='relu')) input_dim : 입력값 갯수model.add(tf.keras.layers.Dense(units=5, activation='relu')) units : 출력값