我们从Python开源项目中,提取了以下5个代码示例,用于说明如何使用data.load_data()。
def load_data(): data = np.empty((42000,1,28,28),dtype="float32") #empty?ones???????????????????? label = np.empty((42000,),dtype="uint8") imgs = os.listdir("./mnist") #????????? num = len(imgs) for i in range(num): img = Image.open("./mnist/"+imgs[i]) #???????Image???? arr = np.asarray(img,dtype="float32") #?img????????? data[i,:,:,:] = arr #?????????data label[i] = int(imgs[i].split('.')[0]) #????????????? return data,label
def _processed_file(self, fname): data_manager = data.load_data(fname) if data_manager is not None: self._add_tab(data_manager, len(self._tabs))
def main(fname=None): data_manager = None if fname is not None: data_manager = data.load_data(fname) qApp = QtWidgets.QApplication(sys.argv) logging.info(qApp.primaryScreen().physicalSize()) window = Application(data_manager) window.show() qApp.exec() logging.info("Goodbye")
def process_data(augmentation=2): cifar = load_data() cifar['train']['x'], m, sd = normalize(cifar['train']['x']) cifar['test']['x'], m, sd = normalize(cifar['test']['x'], M=m, Sd=sd) if augmentation > 0: cifar['train']['x'], cifar['train']['y'] = pad_rightleft(cifar['train']['x'], cifar['train']['y'], mixratio=augmentation) if augmentation > 1.0: cifar['train']['x'], cifar['train']['y'] = pad_addnoise(cifar['train']['x'], cifar['train']['y'], mixratio=augmentation - 1.0) # data.save_pkl(cifar, savename='cifar_processed.pkl') return cifar
def load_data(): cifar = data.load_data() cifar['train']['x'] = cifar['train']['x'].astype(np.float32) cifar['test']['x'] = cifar['test']['x'].astype(np.float32) cifar['train']['x'] /= 255 cifar['test']['x'] /= 255 cifar['train']['y'] = np.array(cifar['train']['y'], dtype=np.int32) cifar['test']['y'] = np.array(cifar['test']['y'], dtype=np.int32) return cifar