crop_yield_prediction/dataloader/cnn_lstm_dataloader.py [20:51]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def __init__(self, data_dir, start_index, end_index, y, n_tsteps, max_index, n_triplets_per_file):
        self.data_dir = data_dir
        self.start_index = start_index
        self.end_index = end_index
        self.n_triplets = end_index - start_index + 1
        self.n_triplets_per_file = n_triplets_per_file
        self.y = y
        self.n_tsteps = n_tsteps
        self.max_index = max_index
        if n_triplets_per_file == (max_index + 1):
            self.X_data = np.load('{}/0_{}.npy'.format(data_dir, max_index))

    def __len__(self):
        return self.n_triplets

    def __getitem__(self, idx):
        global_idx = idx + self.start_index

        if self.n_triplets_per_file == (self.max_index + 1):
            X_idx = self.X_data[global_idx][:self.n_tsteps]
        else:
            if self.n_triplets_per_file > 1:
                file_idx = global_idx // self.n_triplets_per_file
                local_idx = global_idx % self.n_triplets_per_file

                end_idx = min((file_idx+1)*self.n_triplets_per_file-1, self.max_index)
                X_idx = np.load('{}/{}_{}.npy'.format(self.data_dir,
                                                      file_idx * self.n_triplets_per_file,
                                                      end_idx))[local_idx][:self.n_tsteps]
            else:
                X_idx = np.load('{}/{}.npy'.format(self.data_dir, global_idx))[0][:self.n_tsteps]
        y_idx = np.array(self.y[idx])
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



crop_yield_prediction/dataloader/semi_cropyield_dataloader.py [20:51]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    def __init__(self, data_dir, start_index, end_index, y, n_tsteps, max_index, n_triplets_per_file):
        self.data_dir = data_dir
        self.start_index = start_index
        self.end_index = end_index
        self.n_triplets = end_index - start_index + 1
        self.n_triplets_per_file = n_triplets_per_file
        self.y = y
        self.n_tsteps = n_tsteps
        self.max_index = max_index
        if n_triplets_per_file == (max_index + 1):
            self.X_data = np.load('{}/0_{}.npy'.format(data_dir, max_index))

    def __len__(self):
        return self.n_triplets

    def __getitem__(self, idx):
        global_idx = idx + self.start_index

        if self.n_triplets_per_file == (self.max_index + 1):
            X_idx = self.X_data[global_idx][:self.n_tsteps]
        else:
            if self.n_triplets_per_file > 1:
                file_idx = global_idx // self.n_triplets_per_file
                local_idx = global_idx % self.n_triplets_per_file

                end_idx = min((file_idx+1)*self.n_triplets_per_file-1, self.max_index)
                X_idx = np.load('{}/{}_{}.npy'.format(self.data_dir,
                                                      file_idx * self.n_triplets_per_file,
                                                      end_idx))[local_idx][:self.n_tsteps]
            else:
                X_idx = np.load('{}/{}.npy'.format(self.data_dir, global_idx))[0][:self.n_tsteps]
        y_idx = np.array(self.y[idx])
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



