Notice
Recent Posts
Recent Comments
Link
250x250
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 알고리즘
- 운영체제
- TensorFlow
- 텐서플로우
- 시스템프로그래밍
- C언어
- error
- 쉘
- 프로세스
- 공부
- Windows10
- Windows 10
- 코딩
- c
- Computer Vision
- 리눅스
- CV
- 턱걸이
- 백준
- C++
- python
- linux
- 회귀
- 딥러닝
- shell
- 프로그래밍
- 영상처리
- 학습
- OpenCV
- 백준알고리즘
Archives
- Today
- Total
줘이리의 인생적기
[tensorflow 13] 딥러닝 네트워크 회귀 본문
728x90
앞서 배웠던 것들로 학령인구와, 노령인구의 경향을 나타내주는 딥러닝 네트워크 회귀선을 만들어 보겠습니다.
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
#X = school_age_population, Y = elderly_population
X = [16.4, 14.7, 17.2, 16.6, 17.1, 20.3, 17.2, 15.6, 17.4, 18.7, 16.9, 17.1, 15.8, 19.3, 16.6, 15.1, 17.9]
Y = [11.4, 13.2, 11.1, 17.6, 16.3, 9.2, 15.2, 18.4, 18.5, 11.6, 13.7, 9.7, 21.5, 12.0, 14.5, 15.8, 14.0]
model = tf.keras.Sequential([
tf.keras.layers.Dense(units=6, activation='sigmoid', input_shape=(1,)),
tf.keras.layers.Dense(units=1)
])
model.compile(optimizer=tf.keras.optimizers.SGD(lr=0.05), loss='mse')
model.fit(X, Y, epochs=50)
x = np.arange(min(X), max(X), 0.01)
y = model.predict(x)
plt.plot(x, y, 'r-')
plt.plot(X, Y, 'ko')
plt.xlabel('school_age_population(%)')
plt.ylabel('elderly_population(%)')
plt.show()
2개의 Dense 레이어로 구성하였습니다
첫 번째 Dense 레이어는 6개의 뉴런을 할당하였고, sigmoid 활성화 함수를 사용하였습니다.
두 번째 Dense 레이어는 하나의 Y값만 출력하기 위해 1개의 뉴런수를 할당하였습니다.
optimizer는 평균 제곱 오차(Mean Squared Error)를 사용하였습니다.
이런 결과가 나왔네요.
40epoch부터 loss가 줄어들지 않네요.
앞서 구현하였던 다항회귀선과는 다른 회귀선이 나왔습니다.
'공부 > tensorflow' 카테고리의 다른 글
[tensorflow 15] 보스턴 주택 가격 예측 네트워크02 (0) | 2021.04.26 |
---|---|
[tensorflow 14] 보스턴 주택 가격 예측 네트워크01 (0) | 2021.04.23 |
[tensorflow 12] 다항회귀 (0) | 2021.04.21 |
[tensorflow 11] 선형회귀02 (0) | 2021.04.20 |
[tensorflow 10] 선형회귀01 (0) | 2021.04.14 |