Last active
March 4, 2018 23:37
-
-
Save eisenjulian/d13818dcb6487f2c9f85c42e09c9efed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| x_len_train = np.array([min(len(x), sentence_size) for x in x_train_variable]) | |
| x_len_test = np.array([min(len(x), sentence_size) for x in x_test_variable]) | |
| def parser(x, length, y): | |
| features = {"x": x, "len": length} | |
| return features, y | |
| def train_input_fn(): | |
| dataset = tf.data.Dataset.from_tensor_slices((x_train, x_len_train, y_train)) | |
| dataset = dataset.shuffle(buffer_size=25000) | |
| dataset = dataset.batch(100) | |
| dataset = dataset.map(parser) | |
| dataset = dataset.repeat() | |
| iterator = dataset.make_one_shot_iterator() | |
| return iterator.get_next() | |
| def eval_input_fn(): | |
| dataset = tf.data.Dataset.from_tensor_slices((x_test, x_len_test, y_test)) | |
| dataset = dataset.batch(100) | |
| dataset = dataset.map(parser) | |
| iterator = dataset.make_one_shot_iterator() | |
| return iterator.get_next() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment