Skip to content

Commit

Permalink
Save results at the end of training
Browse files Browse the repository at this point in the history
  • Loading branch information
jimfleming committed Mar 21, 2016
1 parent dd871ab commit e2218f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
.env/
.ipynb_checkpoints/
ptb/
logs/
models/

12 changes: 7 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os
import time
import numpy as np
import pandas as pd
import tensorflow as tf

from tensorflow.models.rnn import rnn_cell
Expand All @@ -27,6 +28,7 @@
# define artifact directories where results from the session can be saved
model_path = os.environ.get('MODEL_PATH', 'models/')
checkpoint_path = os.environ.get('CHECKPOINT_PATH', 'checkpoints/')
summary_path = os.environ.get('SUMMARY_PATH', 'logs/')

# load dataset
train_data, valid_data, test_data, _ = ptb_reader.ptb_raw_data("ptb")
Expand Down Expand Up @@ -213,13 +215,13 @@ class Config(object):
valid_costs.append(valid_cost)
valid_perps.append(valid_perp)

write_csv(train_costs, os.path.join(summary_path, "train_costs.csv"))
write_csv(train_perps, os.path.join(summary_path, "train_perps.csv"))
write_csv(valid_costs, os.path.join(summary_path, "valid_costs.csv"))
write_csv(valid_perps, os.path.join(summary_path, "valid_perps.csv"))

saver.save(sess, checkpoint_path + 'checkpoint')

# run test pass
test_cost, test_perp = run_epoch(sess, test_model, test_data)
print("Test Perplexity: %.3f (Cost: %.3f)" % (test_perp, test_cost))

write_csv(train_costs, os.path.join(summary_path, "train_costs.csv"))
write_csv(train_perps, os.path.join(summary_path, "train_perps.csv"))
write_csv(valid_costs, os.path.join(summary_path, "valid_costs.csv"))
write_csv(valid_perps, os.path.join(summary_path, "valid_perps.csv"))

0 comments on commit e2218f4

Please sign in to comment.