본문 바로가기
Deep learning/0x02-simple test

model( 모델 정의 )-동영상 필기 자료 ][ 테스트 해보기 : Y = 3x , input 자동

by SpeeDr00t 2020. 1. 9.
반응형

model( 모델 정의 )-동영상 필기 자료 ][ 테스트 해보기 : Y = 3x , input 자동

개선하기 전 코드  : https://speedr00t.tistory.com/773

 

model( 모델 정의 )-동영상 필기 자료 ][ 테스트 해보기 : Y = 3x

model( 모델 정의 )-동영상 필기 자료 ][ 테스트 해보기 : Y = 3x 필기내용 : https://speedr00t.tistory.com/770 dictionary][ model( 모델 정의 )-동영상 필기 자료 그 동안 체득한 습관으로는 deep learning 정..

speedr00t.tistory.com

 

#
# test by kyoung chip, jang
#
import numpy as np
import keras
from matplotlib import pyplot
def calc( x ) :
return( x*3 )
model = keras.Sequential([keras.layers.Dense(units=1,input_shape=[1])])
model.compile( optimizer='sgd',loss='mean_squared_error')
# y = 3x
x = np.arange( -5.0, 5.0, 1.0) # x = np.array([-5.0,-4.0,..etc] , dtype=float )
y = [ calc( xe ) for xe in x ] # y = np.array([-15.0,-12.0,..etc] , dtype=float )
model.fit( x , y, epochs=500)
# y = 3x
# x = 10.0
# y = 3 * 10.0
print( model.predict([10.0]))
pyplot.plot( x , y )
pyplot.show()
view raw ex2.py hosted with ❤ by GitHub

반응형