Пример #1
0
    def train(self):
        # self.trainBuntton["state"] = 'disabled'
        #sizes, epochs, eta, update_queue, validation_threshold, error_threshold
        trainingPercent = int(self.trainingPercent.get())
        epochs = int(self.epochs.get())
        et = float(self.error_threshold.get())
        vt = int(self.validation_threshold.get())
        poolinRule = self.poolingRule.get()
        mini_batch_size = int(self.mini_batch_size.get())

        try:
            import pickle
            weights = pickle.load(open(self.address.get(), "rb"))
        except:
            weights = None

        if not self.plotter.is_alive():
            self.plotter.start()

        if self.cnn is not None:
            if self.cnn.exitcode != 0:
                print 'Another learner is working.'
                return
            self.cnn.terminate()

        # # self.cnn = CNN.Network(sizes, epochs, eta, mu, self.updatesQueue, vt, et, widrow, bs, activationFunc, weights)
        # self.cnn = CNN.Network([CNN.ConvPoolLayer(image_shape=(mini_batch_size, 1, 28, 28), filter_shape=(20, 1, 5, 5), poolsize=(2, 2)),
        #                         CNN.FullyConnectedLayer(n_in=20*12*12, n_out=100),
        #                         CNN.SoftmaxLayer(n_in=100, n_out=10)], mini_batch_size, self.updatesQueue)

        self.cnn = CNN.Network([
            CNN.ConvPoolLayer(image_shape=(mini_batch_size, 1, 28, 28),
                              filter_shape=(20, 1, 5, 5),
                              poolsize=(2, 2)),
            CNN.ConvPoolLayer(image_shape=(mini_batch_size, 20, 12, 12),
                              filter_shape=(30, 20, 5, 5),
                              poolsize=(2, 2)),
            CNN.ConvPoolLayer(image_shape=(mini_batch_size, 30, 4, 4),
                              filter_shape=(40, 30, 2, 2),
                              poolsize=(3, 3)),
            CNN.FullyConnectedLayer(n_in=40 * 1 * 1, n_out=100),
            CNN.SoftmaxLayer(n_in=100, n_out=10)
        ], mini_batch_size, self.updatesQueue)
        self.cnn.start()