Skip to content

Commit

Permalink
fix summaries and cast bug
Browse files Browse the repository at this point in the history
  • Loading branch information
awni committed Mar 17, 2017
1 parent fb44e15 commit 5077b14
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions network.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def init_loss(self):
self.loss = tf.reduce_mean(losses)

correct = tf.equal(tf.argmax(self.logits, 2), self.labels)
self.acc = tf.reduce_mean(correct)
self.acc = tf.reduce_mean(tf.cast(correct, tf.float32))

def init_train(self, config):

Expand All @@ -65,8 +65,8 @@ def init_train(self, config):
self.avg_loss = ema.average(self.loss)
self.avg_acc = ema.average(self.acc)

tf.scalar_summary("Loss", self.loss)
tf.scalar_summary("Accuracy", self.acc)
tf.summary.scalar("Loss", self.loss)
tf.summary.scalar("Accuracy", self.acc)

self.it = tf.Variable(0, trainable=False, dtype=tf.int64)

Expand Down
4 changes: 2 additions & 2 deletions train.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
FLAGS = tf.flags.FLAGS

def run_epoch(model, data_loader, session, summarizer):
summary_op = tf.merge_all_summaries()
summary_op = tf.summary.merge_all()

for batch in data_loader.batches(data_loader.train):
ops = [model.train_op, model.avg_loss,
Expand Down Expand Up @@ -76,7 +76,7 @@ def main(argv=None):
model.init_train(config['optimizer'])
tf.global_variables_initializer().run()
saver = tf.train.Saver(tf.global_variables())
summarizer = tf.train.SummaryWriter(save_path, sess.graph)
summarizer = tf.summary.FileWriter(save_path, sess.graph)
for e in range(epochs):
start = time.time()
run_epoch(model, data_loader, sess, summarizer)
Expand Down

0 comments on commit 5077b14

Please sign in to comment.