Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 41881b9

Browse files
alanyeeVijay Vasudevan
authored andcommitted
Update wide_n_deep_tutorial.py (tensorflow#11722)
-mkdtemp is low-level, and creates a temporary file somewhere out of sight that requires users to delete the file themselves. For the use case of a tutorial, it is best to use a method that cleanups the file when finished -TemporaryFile does such as described above, but not available in Python 2
1 parent 678db4b commit 41881b9

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tensorflow/examples/learn/wide_n_deep_tutorial.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
from __future__ import print_function
1919

2020
import argparse
21+
import shutil
2122
import sys
2223
import tempfile
2324

@@ -175,6 +176,7 @@ def input_fn(data_file, num_epochs, shuffle):
175176
def train_and_eval(model_dir, model_type, train_steps, train_data, test_data):
176177
"""Train and evaluate the model."""
177178
train_file_name, test_file_name = maybe_download(train_data, test_data)
179+
# Specify file path below if want to find the output easily
178180
model_dir = tempfile.mkdtemp() if not model_dir else model_dir
179181

180182
m = build_estimator(model_dir, model_type)
@@ -189,6 +191,8 @@ def train_and_eval(model_dir, model_type, train_steps, train_data, test_data):
189191
print("model directory = %s" % model_dir)
190192
for key in sorted(results):
191193
print("%s: %s" % (key, results[key]))
194+
# Manual cleanup
195+
shutil.rmtree(model_dir)
192196

193197

194198
FLAGS = None

0 commit comments

Comments
 (0)