Created
September 20, 2018 15:06
-
-
Save ImadDabbura/c9acd3854e54fe9b778ba3310073134a to your computer and use it in GitHub Desktop.
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 training dataset | |
train_dataset = h5py.File("../data/train_catvnoncat.h5") | |
X_train = np.array(train_dataset["train_set_x"]) | |
y_train = np.array(train_dataset["train_set_y"]) | |
test_dataset = h5py.File("../data/test_catvnoncat.h5") | |
X_test = np.array(test_dataset["test_set_x"]) | |
y_test = np.array(test_dataset["test_set_y"]) | |
# print the shape of input data and label vector | |
print(f"""Original dimensions:\n{20 * '-'}\nTraining: {X_train.shape}, {y_train.shape} | |
Test: {X_test.shape}, {y_test.shape}""") | |
# plot cat image | |
plt.figure(figsize=(6, 6)) | |
plt.imshow(X_train[50]) | |
plt.axis("off"); | |
# Transform input data and label vector | |
X_train = X_train.reshape(209, -1).T | |
y_train = y_train.reshape(-1, 209) | |
X_test = X_test.reshape(50, -1).T | |
y_test = y_test.reshape(-1, 50) | |
# standardize the data | |
X_train = X_train / 255 | |
X_test = X_test / 255 | |
print(f"""\nNew dimensions:\n{15 * '-'}\nTraining: {X_train.shape}, {y_train.shape} | |
Test: {X_test.shape}, {y_test.shape}""") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment