CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
amanchadha

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: amanchadha/coursera-deep-learning-specialization
Path: blob/master/C1 - Neural Networks and Deep Learning/Week 2/Logistic Regression as a Neural Network/lr_utils.py
Views: 4818
1
import numpy as np
2
import h5py
3
4
5
def load_dataset():
6
train_dataset = h5py.File('datasets/train_catvnoncat.h5', "r")
7
train_set_x_orig = np.array(train_dataset["train_set_x"][:]) # your train set features
8
train_set_y_orig = np.array(train_dataset["train_set_y"][:]) # your train set labels
9
10
test_dataset = h5py.File('datasets/test_catvnoncat.h5', "r")
11
test_set_x_orig = np.array(test_dataset["test_set_x"][:]) # your test set features
12
test_set_y_orig = np.array(test_dataset["test_set_y"][:]) # your test set labels
13
14
classes = np.array(test_dataset["list_classes"][:]) # the list of classes
15
16
train_set_y_orig = train_set_y_orig.reshape((1, train_set_y_orig.shape[0]))
17
test_set_y_orig = test_set_y_orig.reshape((1, test_set_y_orig.shape[0]))
18
19
return train_set_x_orig, train_set_y_orig, test_set_x_orig, test_set_y_orig, classes
20
21
22