| 579 | |
| 580 | |
| 581 | def eval(sess_config, input_hooks, model, test_init_op, test_steps, output_dir, checkpoint_dir): |
| 582 | hooks = [] |
| 583 | hooks.extend(input_hooks) |
| 584 | |
| 585 | scaffold = tf.train.Scaffold( |
| 586 | local_init_op=tf.group(tf.local_variables_initializer(), test_init_op)) |
| 587 | session_creator = tf.train.ChiefSessionCreator( |
| 588 | scaffold=scaffold, checkpoint_dir=checkpoint_dir, config=sess_config) |
| 589 | writer = tf.summary.FileWriter(os.path.join(output_dir, 'eval')) |
| 590 | merged = tf.summary.merge_all() |
| 591 | |
| 592 | with tf.train.MonitoredSession(session_creator=session_creator, |
| 593 | hooks=hooks) as sess: |
| 594 | for _in in range(1, test_steps + 1): |
| 595 | if (_in != test_steps): |
| 596 | sess.run([model.acc_op, model.auc_op]) |
| 597 | if (_in % 1000 == 0): |
| 598 | print(f'Evaluation complete:[{_in}/{test_steps}]') |
| 599 | else: |
| 600 | eval_acc, eval_auc, events = sess.run([model.acc_op, model.auc_op, merged]) |
| 601 | writer.add_summary(events, _in) |
| 602 | print(f'Evaluation complete:[{_in}/{test_steps}]') |
| 603 | print(f'ACC = {eval_acc}\nAUC = {eval_auc}') |
| 604 | |
| 605 | def main(stock_tf, tf_config=None, server=None): |
| 606 | # check dataset and count data set size |