반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

keras.layers.Dropout 본문

[AI]/python.keras

keras.layers.Dropout

givemebro 2020. 5. 13. 17:49
반응형
# drop out : 뉴런 몇개를 막아버린다.
(X_train,y_train),(X_test,y_test)=mnist.load_data()
X_train=X_train/255
X_test=X_test/255
y_train=np.eye(10)[y_train]
y_test=np.eye(10)[y_test]

from keras.layers import Dropout
from keras.layers import Flatten
model=Sequential()
model.add(Flatten(input_shape=(28,28)))
model.add(Dense(128,activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(256,activation='relu'))
model.add(Dropout(0.5))

model.add(Dense(256,activation='relu'))
model.add(Dense(10,activation='softmax'))

 

model.summary()

 

_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
flatten_8 (Flatten)          (None, 784)               0         
_________________________________________________________________
dense_62 (Dense)             (None, 128)               100480    
_________________________________________________________________
dropout_7 (Dropout)          (None, 128)               0         
_________________________________________________________________
dense_63 (Dense)             (None, 256)               33024     
_________________________________________________________________
dropout_8 (Dropout)          (None, 256)               0         
_________________________________________________________________
dense_64 (Dense)             (None, 256)               65792     
_________________________________________________________________
dense_65 (Dense)             (None, 10)                2570      
=================================================================
Total params: 201,866
Trainable params: 201,866
Non-trainable params: 0
_________________________________________________________________

 

# score test
pred_y_test=model.predict(X_test)
(pred_y_test*y_test).sum()/len(y_test)
0.1004556488275528
반응형

'[AI] > python.keras' 카테고리의 다른 글

keras.workflow  (0) 2020.08.10
keras.classifier.cifar10  (0) 2020.06.13
머신러닝 용어집  (0) 2020.06.09
distinguish dog and cat  (0) 2020.06.09
keras.layers.Flatten  (0) 2020.05.13
keras.save  (0) 2020.05.13
keras.score  (0) 2020.05.13
keras.mnist(중간층)  (0) 2020.05.13
Comments