'çšå°Session'

def run(self):

    def print_confusion_matrix(confusionMatrix):
        print('Confusion                Matrix:')
        for (i, line) in enumerate(confusionMatrix):
            print(line, (line[i] / np.sum(line)))
        a = 0
        for (i, column) in enumerate(np.transpose(confusionMatrix, (1, 0))):
            a += ((column[i] / np.sum(column)) * (np.sum(column) / 26000))
            print((column[i] / np.sum(column)))
        print('\n', np.sum(confusionMatrix), a)
    self.session = tf.Session(graph=self.graph)
    with self.session as session:
        tf.initialize_all_variables().run()
        print('Start    Training')
        for (i, samples, labels) in get_chunk(train_samples, train_labels, chunkSize=self.batch_size):
            (_, l, predictions) = session.run([self.optimizer, self.loss, self.train_prediction], feed_dict={self.tf_train_samples: samples, self.tf_train_labels: labels})
            (accuracy, _) = self.accuracy(predictions, labels)
            if ((i % 50) == 0):
                print(('Minibatch    loss    at    step    %d:    %f' % (i, l)))
                print(('Minibatch    accuracy:    %.1f%%' % accuracy))
        accuracies = []
        confusionMatrices = []
        for (i, samples, labels) in get_chunk(test_samples, test_labels, chunkSize=self.test_batch_size):
            result = self.test_prediction.eval(feed_dict={self.tf_test_samples: samples})
            (accuracy, cm) = self.accuracy(result, labels, need_confusion_matrix=True)
            accuracies.append(accuracy)
            confusionMatrices.append(cm)
            print(('Test    Accuracy:    %.1f%%' % accuracy))
        print('    Average        Accuracy:', np.average(accuracies))
        print('Standard    Deviation:', np.std(accuracies))
        print_confusion_matrix(np.add.reduce(confusionMatrices))
