(self)
| 22 | save_path = "" |
| 23 | |
| 24 | def Run(self): |
| 25 | |
| 26 | #defining the model... |
| 27 | self.X = tf.placeholder(tf.float32, shape=[None, self._input.input_size], name="x_input") |
| 28 | self.y = tf.placeholder(tf.float32, shape=[None, self._input.labels_size], name="y_labels") |
| 29 | |
| 30 | _y = self._model.Run(self.X) |
| 31 | _loss = tf.reduce_mean(tf.pow(_y-self.y, 2)) |
| 32 | |
| 33 | correct_pred = tf.equal(tf.argmax(_y, 1), tf.argmax(self.y, 1)) |
| 34 | _accuracy = tf.reduce_mean(tf.cast(correct_pred, tf.float32)) |
| 35 | |
| 36 | _solver = tf.train.AdamOptimizer(self.learning_rate).minimize(_loss) |
| 37 | |
| 38 | instance = AIBlocks.InitModel(load_path=self.save_path) |
| 39 | Log("Model initialized!") |
| 40 | |
| 41 | SetState(self.id, 0.001) |
| 42 | |
| 43 | for it in range(self.training_iterations): |
| 44 | batch = self._input.getNextBatch() |
| 45 | |
| 46 | X_batch = batch[0] |
| 47 | Y_batch = batch[1] |
| 48 | |
| 49 | _, loss, acc = instance.Run([_solver, _loss, _accuracy], feed_dict={self.X: X_batch, self.y: Y_batch}) |
| 50 | |
| 51 | if it % self.display_step == 0: |
| 52 | SetState(self.id, it/self.training_iterations) |
| 53 | SendChartData(self.id, "Loss", loss, "#ff0000") |
| 54 | SendChartData(self.id, "Accuracy", acc) |
| 55 | |
| 56 | AIBlocks.SaveModel(instance) |
| 57 | AIBlocks.CloseSession(instance) |
| 58 |
nothing calls this directly
no test coverage detected