INNER CODE UNIT · Python

__init__

MITDeepLearning/introtodeeplearning · mitdeeplearning/lab2.py:50

    def __init__(self, data_path, channels_last=True):
        print("Opening {}".format(data_path))
        sys.stdout.flush()

        self.cache = h5py.File(data_path, "r")

        print("Loading data into memory...")
        sys.stdout.flush()
        self.images = self.cache["images"][:]
        self.channels_last = channels_last
        self.labels = self.cache["labels"][:].astype(np.float32)
        self.image_dims = self.images.shape
        n_train_samples = self.image_dims[0]

        self.train_inds = np.random.permutation(np.arange(n_train_samples))

        self.pos_train_inds = self.train_inds[self.labels[self.train_inds, 0] == 1.0]
        self.neg_train_inds = self.train_inds[self.labels[self.train_inds, 0] != 1.0]

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…