Exemplo n.º 1
0
    def __init__(self, which_set, center=False, multi_target=False):
        """
        :param which_set: one of ['train','test']
        :param center: data is in range [0,256], center=True subtracts 127.5.
        :param multi_target: load extra information as additional labels.
        """
        assert which_set in ['train', 'test']

        X = FoveatedNORB.load(which_set)

        # put things in pylearn2's DenseDesignMatrix format
        X = numpy.cast['float32'](X)

        #this is uint8
        y = NORBSmall.load(which_set, 'cat')
        if multi_target:
            y_extra = NORBSmall.load(which_set, 'info')
            y = numpy.hstack((y[:, numpy.newaxis], y_extra))

        if center:
            X -= 127.5

        view_converter = retina.RetinaCodingViewConverter((96, 96, 2),
                                                          (8, 4, 2, 2))

        super(FoveatedNORB, self).__init__(X=X,
                                           y=y,
                                           view_converter=view_converter)
Exemplo n.º 2
0
    def __init__(self,
                 which_set,
                 center=False,
                 scale=False,
                 start=None,
                 stop=None,
                 one_hot=False,
                 restrict_instances=None,
                 preprocessor=None):
        """
        :param which_set: one of ['train','test']
        :param center: data is in range [0,256], center=True subtracts 127.5.
        :param multi_target: load extra information as additional labels.
        """
        if which_set not in ['train', 'test']:
            raise ValueError("Unrecognized which_set value: " + which_set)

        X = FoveatedNORB.load(which_set)

        # put things in pylearn2's DenseDesignMatrix format
        X = numpy.cast['float32'](X)

        #this is uint8
        y = NORBSmall.load(which_set, 'cat')
        y_extra = NORBSmall.load(which_set, 'info')

        assert y_extra.shape[0] == y.shape[0]
        instance = y_extra[:, 0]
        assert instance.min() >= 0
        assert instance.max() <= 9
        self.instance = instance

        if center:
            X -= 127.5
            if scale:
                X /= 127.5
        else:
            if scale:
                X /= 255.

        view_converter = retina.RetinaCodingViewConverter((96, 96, 2),
                                                          (8, 4, 2, 2))

        super(FoveatedNORB, self).__init__(X=X,
                                           y=y,
                                           view_converter=view_converter,
                                           preprocessor=preprocessor)

        if one_hot:
            self.convert_to_one_hot()

        if restrict_instances is not None:
            assert start is None
            assert stop is None
            self.restrict_instances(restrict_instances)

        self.restrict(start, stop)

        self.y = self.y.astype('float32')
Exemplo n.º 3
0
    def __init__(self,
                 which_set,
                 center=False,
                 scale=False,
                 start=None,
                 stop=None,
                 one_hot=False,
                 restrict_instances=None,
                 preprocessor=None):

        self.args = locals()

        if which_set not in ['train', 'test']:
            raise ValueError("Unrecognized which_set value: " + which_set)

        X = FoveatedNORB.load(which_set)
        X = numpy.cast['float32'](X)

        # this is uint8
        y = NORBSmall.load(which_set, 'cat')
        y_extra = NORBSmall.load(which_set, 'info')

        assert y_extra.shape[0] == y.shape[0]
        instance = y_extra[:, 0]
        assert instance.min() >= 0
        assert instance.max() <= 9
        self.instance = instance

        if center:
            X -= 127.5
            if scale:
                X /= 127.5
        else:
            if scale:
                X /= 255.

        view_converter = retina.RetinaCodingViewConverter((96, 96, 2),
                                                          (8, 4, 2, 2))

        super(FoveatedNORB, self).__init__(X=X,
                                           y=y,
                                           view_converter=view_converter,
                                           preprocessor=preprocessor)

        if one_hot:
            self.convert_to_one_hot()

        if restrict_instances is not None:
            assert start is None
            assert stop is None
            self.restrict_instances(restrict_instances)

        self.restrict(start, stop)

        self.y = self.y.astype('float32')