Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mengpengfei #24

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: fix the end_cost.
  • Loading branch information
kerlomz authored and mengpengfei committed Jun 13, 2019
commit 28d83224232145fc70bac2e48419ba2cd075777b
6 changes: 3 additions & 3 deletions trains.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def compile_graph(acc):
)

last_compile_model_path = COMPILE_MODEL_PATH.replace('.pb', '_{}.pb'.format(int(acc * 10000)))
with tf.gfile.FastGFile(last_compile_model_path, mode='wb') as gf:
with tf.gfile.GFile(last_compile_model_path, mode='wb') as gf:
gf.write(output_graph_def.SerializeToString())

generate_config(acc)
Expand Down Expand Up @@ -146,7 +146,7 @@ def train_process(mode=RunMode.Trains):
)
train_cost += batch_cost * BATCH_SIZE
avg_train_cost = train_cost / ((cur_batch + 1) * BATCH_SIZE)

_avg_train_cost = avg_train_cost
train_writer.add_summary(summary_str, step)

if step % 100 == 0 and step != 0:
Expand Down Expand Up @@ -186,7 +186,7 @@ def train_process(mode=RunMode.Trains):
print(log.format(
epoch_count, step, accuracy, avg_train_cost, time.time() - batch_time, lr
))
_avg_train_cost = avg_train_cost

if accuracy >= TRAINS_END_ACC and epoch_count >= TRAINS_END_EPOCHS and avg_train_cost <= TRAINS_END_COST:
break
if accuracy >= TRAINS_END_ACC and epoch_count >= TRAINS_END_EPOCHS and _avg_train_cost <= TRAINS_END_COST:
Expand Down
2 changes: 1 addition & 1 deletion tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,6 @@ class RecurrentNetwork:
from make_dataset import run
from trains import main
run()
with open("model.yaml".format(size_str), "w") as f:
with open("model.yaml".format(size_str), "w", encoding="utf8") as f:
f.write("\n".join(result.split("\n")[:-3]).replace("# TrainsPath", " TrainsPath").replace("# TestPath", " TestPath"))
main(None)