GeezerVison is showing github.com — Add a parameter to make the test set smaller · jayakumark/DeepLearningTutorials@26914e4
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: code/lstm.py +4Lines changed: 4 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -395,6 +395,7 @@ def train_lstm( |
395 | 395 | use_dropout=True, # if False slightly faster, but worst test error |
396 | 396 | # This frequently need a bigger model. |
397 | 397 | reload_model="", # Path to a saved model we want to start from. |
| 398 | + test_size=-1, # If >0, we will trunc the test set to this number of example. |
398 | 399 | ): |
399 | 400 |
|
400 | 401 | # Model options |
@@ -406,6 +407,8 @@ def train_lstm( |
406 | 407 | print 'Loading data' |
407 | 408 | train, valid, test = load_data(n_words=n_words, valid_portion=0.05, |
408 | 409 | maxlen=maxlen) |
| 410 | + if test_size > 0: |
| 411 | + test = (test[0][:test_size], test[1][:test_size]) |
409 | 412 |
|
410 | 413 | ydim = numpy.max(train[1]) + 1 |
411 | 414 |
|
@@ -578,4 +581,5 @@ def train_lstm( |
578 | 581 | train_lstm( |
579 | 582 | #reload_model="lstm_model.npz", |
580 | 583 | max_epochs=100, |
| 584 | + test_size=500, |
581 | 585 | ) |