forked from Kaggle/docker-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_keras.py
More file actions
25 lines (18 loc) · 747 Bytes
/
test_keras.py
File metadata and controls
25 lines (18 loc) · 747 Bytes
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
import unittest
import pandas as pd
from keras.models import Sequential
from keras.layers import Dense
from keras.optimizers import RMSprop
from keras.utils.np_utils import to_categorical
class TestKeras(unittest.TestCase):
def test_train(self):
train = pd.read_csv("/input/tests/data/train.csv")
x_train = train.iloc[:,1:].values.astype('float32')
y_train = to_categorical(train.iloc[:,0].astype('int32'))
model = Sequential()
model.add(Dense(units=10, input_dim=784, activation='softmax'))
model.compile(
loss='categorical_crossentropy',
optimizer=RMSprop(lr=0.001),
metrics=['accuracy'])
model.fit(x_train, y_train, epochs=1, batch_size=32)