Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

머신러닝스터디/2016/2016 06 11: Difference between revisions

From ZeroWiki
No edit summary
imported>rabierre
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
[[pagelist(^(머신러닝스터디/2016))]]
[[머신러닝스터디/2016]]
[[머신러닝스터디/2016/목차]]
== 내용 ==
== 내용 ==
* keras 사용
* keras 사용
Line 28: Line 29:
               metrics=['accuracy'])
               metrics=['accuracy'])
   
   
   
  # y_train and y_test is simple integer of 0 to 9
# Need to be transformed to array
  y_train_array = np.zeros((60000, 10))
  y_train_array = np.zeros((60000, 10))
  y_test_array = np.zeros((10000, 10))
  y_test_array = np.zeros((10000, 10))
Line 45: Line 47:
  print(score)
  print(score)
== 후기 ==
== 후기 ==
* [[서지혜]]: 맥에어에서 돌렸더니 엄청 오래걸렸다.. 클라우드 세팅해야될거같음. 아래는 결과물. 다 돌리고 출력을 어떻게 해야할지 모르겠네.
Using Theano backend.
Epoch 1/3
60000/60000 [==============================] - 3122s - loss: 14.4306 - acc: 0.1047   
Epoch 2/3
60000/60000 [==============================] - 3055s - loss: 14.4370 - acc: 0.1043   
Epoch 3/3
60000/60000 [==============================] - 3135s - loss: 14.4453 - acc: 0.1038   
10000/10000 [==============================] - 398s
[14.461154937744141, 0.10279999673366547]
== 다음 시간에는 ==
== 다음 시간에는 ==
* Week 6 보기
* Week 6 보기

Latest revision as of 17:33, 24 July 2016

머신러닝스터디/2016 머신러닝스터디/2016/목차

내용

코드

from keras.models import Sequential
from keras.layers import Dense, Dropout, Activation
from keras.datasets import mnist
from keras.layers.core import Reshape
import numpy as np

(X_train, y_train), (X_test, y_test) = mnist.load_data()

model = Sequential()
model.add(Reshape((28*28,), input_shape=(28,28)))
model.add(Dense(60000, input_dim=28*28, activation='relu'))

model.add(Dropout(0.5))
model.add(Dense(64, activation='relu'))

model.add(Dropout(0.5))
model.add(Dense(10, activation='softmax'))

model.compile(loss='categorical_crossentropy',
              optimizer='adagrad',
              metrics=['accuracy'])

# y_train and y_test is simple integer of 0 to 9
# Need to be transformed to array
y_train_array = np.zeros((60000, 10))
y_test_array = np.zeros((10000, 10))
for i in range(60000):
  y_train_array[i][y_train[i]] = 1
for i in range(10000):
  y_test_array[i][y_test[i]] = 1

model.fit(X_train, y_train_array,
          nb_epoch=3,
          batch_size=16)

score = model.evaluate(X_test, y_test_array, batch_size=10000)

# TODO
print(score)

후기

  • 서지혜: 맥에어에서 돌렸더니 엄청 오래걸렸다.. 클라우드 세팅해야될거같음. 아래는 결과물. 다 돌리고 출력을 어떻게 해야할지 모르겠네.
Using Theano backend.
Epoch 1/3
60000/60000 [==============================] - 3122s - loss: 14.4306 - acc: 0.1047     
Epoch 2/3
60000/60000 [==============================] - 3055s - loss: 14.4370 - acc: 0.1043     
Epoch 3/3
60000/60000 [==============================] - 3135s - loss: 14.4453 - acc: 0.1038     

10000/10000 [==============================] - 398s
[14.461154937744141, 0.10279999673366547]

다음 시간에는

  • Week 6 보기

더 보기

[1] [2]