Last active
December 7, 2020 04:10
-
-
Save Crazz-Zaac/3ea01fcc43ec16f8bb7c2d5cf667abd4 to your computer and use it in GitHub Desktop.
Importing image dataset as train and test set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
import h5py | |
import scipy | |
from PIL import Image | |
from scipy import ndimage | |
%matplotlib inline #to set the backend of matplotlib to the 'inline' backend | |
def load_dataset(): | |
train_dataset = h5py.File('catdataset/train_catvnoncat.h5', "r") | |
train_set_x_orig = np.array(train_dataset["train_set_x"][:]) # your train set features | |
train_set_y_orig = np.array(train_dataset["train_set_y"][:]) # your train set labels | |
test_dataset = h5py.File('catdataset/test_catvnoncat.h5', "r") | |
test_set_x_orig = np.array(test_dataset["test_set_x"][:]) # your test set features | |
test_set_y_orig = np.array(test_dataset["test_set_y"][:]) # your test set labels | |
classes = np.array(test_dataset["list_classes"][:]) # the list of classes | |
train_set_y_orig = train_set_y_orig.reshape((1, train_set_y_orig.shape[0])) | |
test_set_y_orig = test_set_y_orig.reshape((1, test_set_y_orig.shape[0])) | |
return train_set_x_orig, train_set_y_orig, test_set_x_orig, test_set_y_orig, classes | |
# Loading the data (cat/non-cat) | |
train_set_x_orig, train_set_y, test_set_x_orig, test_set_y, classes = load_dataset() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment