|
29 | 29 | parser.add_argument("--vocab_size", type=int, default=None,
|
30 | 30 | help="Vocabulary size (default: None [see data.py])")
|
31 | 31 |
|
| 32 | +parser.add_argument("--test", action="store_false", dest="validation", |
| 33 | + help="Include this flag if models should be tuned on the test set instead.") |
| 34 | +parser.set_defaults(validation=True) |
| 35 | + |
32 | 36 | args = parser.parse_args()
|
33 | 37 |
|
34 | 38 |
|
@@ -119,15 +123,20 @@ def run_experiment(x_train, y_train, x_valid, y_valid, embeddings, _num_edges, _
|
119 | 123 | # ==================================================
|
120 | 124 |
|
121 | 125 | train, test = data.load_dataset(args.dataset, out="tfidf", vocab_size=10000)
|
122 |
| -del test |
123 | 126 |
|
124 | 127 | x_train = train.data.astype(np.float32)
|
125 | 128 | y_train = train.labels
|
126 | 129 |
|
127 |
| -# Split training set & validation set |
128 |
| -validation_index = -1 * int(0.1 * float(len(y_train))) |
129 |
| -x_train, x_valid = x_train[:validation_index], x_train[validation_index:] |
130 |
| -y_train, y_valid = y_train[:validation_index], y_train[validation_index:] |
| 130 | +if args.validation: |
| 131 | + del test # don't need this anymore |
| 132 | + |
| 133 | + # Split training set & validation set |
| 134 | + validation_index = -1 * int(0.1 * float(len(y_train))) |
| 135 | + x_train, x_valid = x_train[:validation_index], x_train[validation_index:] |
| 136 | + y_train, y_valid = y_train[:validation_index], y_train[validation_index:] |
| 137 | +else: |
| 138 | + x_valid = test.data.astype(np.float32) |
| 139 | + y_valid = test.labels |
131 | 140 |
|
132 | 141 | # Construct reverse lookup vocabulary
|
133 | 142 | reverse_vocab = {w: i for i, w in enumerate(train.vocab)}
|
|
0 commit comments