Skip to content

Commit

Permalink
Remove class_mode, add support for acc in Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
fchollet committed Mar 12, 2016
1 parent 70431a5 commit 0c1af09
Show file tree
Hide file tree
Showing 6 changed files with 211 additions and 50 deletions.
5 changes: 1 addition & 4 deletions docs/templates/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,8 @@ model.add(Dense(64, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(1, activation='sigmoid'))

# "class_mode" defaults to "categorical". For correctly displaying accuracy
# in a binary classification problem, it should be set to "binary".
model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
class_mode='binary')
optimizer='rmsprop')
```

------------------
Expand Down
2 changes: 1 addition & 1 deletion examples/imdb_bidirectional_lstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
print('Train...')
model.fit({'input': X_train, 'output': y_train},
batch_size=batch_size,
nb_epoch=4)
nb_epoch=4, show_accuracy=True)
acc = accuracy(y_test,
np.round(np.array(model.predict({'input': X_test},
batch_size=batch_size)['output'])))
Expand Down
3 changes: 1 addition & 2 deletions examples/imdb_cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@
model.add(Activation('sigmoid'))

model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
class_mode='binary')
optimizer='rmsprop')
model.fit(X_train, y_train, batch_size=batch_size,
nb_epoch=nb_epoch, show_accuracy=True,
validation_data=(X_test, y_test))
7 changes: 3 additions & 4 deletions examples/imdb_lstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
print(len(X_train), 'train sequences')
print(len(X_test), 'test sequences')

print("Pad sequences (samples x time)")
print('Pad sequences (samples x time)')
X_train = sequence.pad_sequences(X_train, maxlen=maxlen)
X_test = sequence.pad_sequences(X_test, maxlen=maxlen)
print('X_train shape:', X_train.shape)
Expand All @@ -54,10 +54,9 @@

# try using different optimizers and different optimizer configs
model.compile(loss='binary_crossentropy',
optimizer='adam',
class_mode="binary")
optimizer='adam')

print("Train...")
print('Train...')
model.fit(X_train, y_train, batch_size=batch_size, nb_epoch=15,
validation_data=(X_test, y_test), show_accuracy=True)
score, acc = model.evaluate(X_test, y_test,
Expand Down
Loading

0 comments on commit 0c1af09

Please sign in to comment.