Exemplo n.º 1
0
    def get_next(self, set):
        """
        Get next preprocessed batch
        """
        raw_data = tf.placeholder(tf.float32, shape=[None, 3, 32, 32])
        preprocessor = Preprocessor(raw_data,
                                    centered=self.centered,
                                    rescaled=self.rescaled,
                                    grayscale=self.grayscale,
                                    shaped=self.shaped)

        if set == "train":
            batch = self.train_batch
            size = self.batch_size
            raw_x, y_batch = batch.get_next()
        elif set == "train_acc":
            batch = self.train_batch
            size = self.accuracy_size
            raw_x, y_batch = batch.get_first_size(self.accuracy_size)
        elif set == "test_acc":
            batch = self.test_batch
            size = self.validation_size
            raw_x, y_batch = batch.get_first_size(self.validation_size)

        with tf.Session() as sess:
            raw_x = raw_x.reshape(-1, 3, 32, 32)
            x_batch = sess.run(preprocessor.apply(raw_x, size),
                               feed_dict={raw_data: raw_x})
        return x_batch, y_batch