def load_datasets():
train_file = r'D:\CNMU\AI\1X\datasets\train_catvnoncat.h5'
test_file = r'D:\CNMU\AI\1X\datasets\test_catvnoncat.h5'
train_datasets = h5py.File(train_file,'r')
# train_datasets.keys()
# <KeysViewHDF5 ['list_classes', 'train_set_x', 'train_set_y']>
train_set_x = np.array(train_datasets['train_set_x'])
train_set_y = np.array(train_datasets['train_set_y'])
test_datasets = h5py.File(test_file,'r')
test_set_x = np.array(test_datasets['test_set_x'])
test_set_y = np.array(test_datasets['test_set_y'])
classes = np.array(test_datasets['list_classes'])
train_set_y = train_set_y.reshape(1,train_set_x.shape[0])
test_set_y = test_set_y.reshape(1,test_set_x.shape[0])
return train_set_x,train_set_y,test_set_x,test_set_y,classes
Here, return returns five arrays and a tuple of five elements;
train_set_x,train_set_y,test_set_x,test_set_y,classes = load_datasets()
With this assignment, you can call each array directly
Read More:
- Python Valueerror: cannot index with vector containing Na / Nan values
- Python errors: valueerror: if using all scalar values, you must pass an index (four solutions)
- Python synthesizes multiple pictures into one video
- How to Solve Python WARNING: Ignoring invalid distribution -ip (e:\python\python_dowmload\lib\site-packages)
- [Solved] PyInstaller Error: ValueError: too many values to unpack
- Python Redis: How to batch fuzzy Delete Keys
- How to Fix keyerror in Python dictionary lookup
- An introduction to sys modules in Python and how packages are imported and used
- How to Solve Python Importerror: DLL load failed: unable to find the specified program using tensorflow
- Python: How to Auto Add Watermark to PDF
- Python: How to Obtaining Publick IP Quickly
- [CHM] Python: How to Extract CHM Data
- How to Solve Python Xlwt ValueError: More than 4094 XFs (styles)
- Python 2.7: How to Install PIP
- Python: How to Disable InsecureRequestWarning error
- Python: How to Solve error While importing windpy
- How to Solve Python3.9 Install pycrypto Error
- How to Fix “HTTP error 403: forbidden” in Python 3. X
- Python: How to Reshape the data in Pandas DataFrame
- How to Fix Errors encountered in executing Python scripts with command line parameters