@@ 625-639 (lines=15) @@ | ||
622 | feed_dict={self.x: batch_x, self.y_: batch_y, self.length: batch_size, |
|
623 | self.init_state: np.zeros(2 * self.num_units)}) |
|
624 | # Summary |
|
625 | if summaries_dir is not None and (i % summary_interval == 0): |
|
626 | summary, loss, accuracy = session.run( |
|
627 | [self.merged, self.loss, self.accuracy], |
|
628 | feed_dict={self.x: x, self.y_: y, self.length: num_samples - valid_set_len - num_skip, |
|
629 | self.init_state: np.zeros(2 * self.num_units)} |
|
630 | ) |
|
631 | train_writer.add_summary(summary, i) |
|
632 | logger.info('Step %d, train_set accuracy %g, loss %g' % (i, accuracy, loss)) |
|
633 | if (test_x is not None) and (test_y is not None): |
|
634 | merged, accuracy = session.run( |
|
635 | [self.merged, self.accuracy], |
|
636 | feed_dict={self.x: test_x, self.y_: test_y, self.length: test_x.shape[0] - num_skip, |
|
637 | self.init_state: np.zeros(2*self.num_units)}) |
|
638 | test_writer.add_summary(merged, i) |
|
639 | logger.info('test_set accuracy %g' % accuracy) |
|
640 | # Get Summary |
|
641 | if i == x.shape[0] - num_skip: |
|
642 | i = 0 |
|
@@ 127-141 (lines=15) @@ | ||
124 | i = 0 |
|
125 | while _criterion.continue_learning(): |
|
126 | batch_x, batch_y = injector.next_batch() |
|
127 | if summaries_dir is not None and (i % summary_interval == 0): |
|
128 | summary, loss, accuracy = session.run( |
|
129 | [self.merged, self.loss, self.accuracy], |
|
130 | feed_dict={self.x: train_seq_x, self.y_: train_seq_y, |
|
131 | self.init_state: np.zeros((train_seq_x.shape[0], 2 * self.num_units))} |
|
132 | ) |
|
133 | train_writer.add_summary(summary, i) |
|
134 | logger.info('Step %d, train_set accuracy %g, loss %g' % (i, accuracy, loss)) |
|
135 | if (test_x is not None) and (test_y is not None): |
|
136 | merged, accuracy = session.run( |
|
137 | [self.merged, self.accuracy], |
|
138 | feed_dict={self.x: test_seq_x, self.y_: test_seq_y, |
|
139 | self.init_state: np.zeros((test_seq_x.shape[0], 2*self.num_units))}) |
|
140 | test_writer.add_summary(merged, i) |
|
141 | logger.info('test_set accuracy %g' % accuracy) |
|
142 | loss, accuracy, _ = session.run( |
|
143 | [self.loss, self.accuracy, self.fit_step], |
|
144 | feed_dict={self.x: batch_x, self.y_: batch_y, |