본문 바로가기
IT공부/인공지능-딥러닝,머신러닝

딥러닝 실습

by 초보전산 2020. 11. 1.
반응형

1. 딥러닝 Flow

 

 

 

deep_1

In [5]:
import numpy as np

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from keras import optimizers
In [17]:
#데이터셋 설정
time = np.array([1,2,3,4,5])
score= np.array([10,20,30,60,66])
In [18]:
#모델구성
model=Sequential()
model.add(Dense(1,input_dim=1, activation='linear')) #선형회귀
In [19]:
#모델컴파일
sgd= optimizers.SGD(lr=0.01)
model.compile(optimizer=sgd,loss='mse', metrics=['accuracy']) #평가기준:정확도
In [20]:
#모델학습
model.fit(time,score,batch_size=1,epochs=5,shuffle=False)
Epoch 1/5
5/5 [==============================] - 0s 2ms/step - loss: 733.3189 - accuracy: 0.0000e+00
Epoch 2/5
5/5 [==============================] - 0s 3ms/step - loss: 83.2137 - accuracy: 0.0000e+00
Epoch 3/5
5/5 [==============================] - 0s 3ms/step - loss: 58.2496 - accuracy: 0.0000e+00
Epoch 4/5
5/5 [==============================] - 0s 3ms/step - loss: 57.9678 - accuracy: 0.0000e+00
Epoch 5/5
5/5 [==============================] - 0s 3ms/step - loss: 57.5347 - accuracy: 0.0000e+00
Out[20]:
<tensorflow.python.keras.callbacks.History at 0x223c3049460>
In [21]:
#모델예측
print(model.predict([7])) #time이 7일때 예상 score?
[[90.83037]]
In [ ]:
 

 

 

*설명

반응형

댓글