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/C4 - Convolutional Neural Networks/Week 2/KerasTutorial/kt_utils.py
Views: 4804
1
import keras.backend as K
2
import math
3
import numpy as np
4
import h5py
5
import matplotlib.pyplot as plt
6
7
8
def mean_pred(y_true, y_pred):
9
return K.mean(y_pred)
10
11
def load_dataset():
12
train_dataset = h5py.File('datasets/train_happy.h5', "r")
13
train_set_x_orig = np.array(train_dataset["train_set_x"][:]) # your train set features
14
train_set_y_orig = np.array(train_dataset["train_set_y"][:]) # your train set labels
15
16
test_dataset = h5py.File('datasets/test_happy.h5', "r")
17
test_set_x_orig = np.array(test_dataset["test_set_x"][:]) # your test set features
18
test_set_y_orig = np.array(test_dataset["test_set_y"][:]) # your test set labels
19
20
classes = np.array(test_dataset["list_classes"][:]) # the list of classes
21
22
train_set_y_orig = train_set_y_orig.reshape((1, train_set_y_orig.shape[0]))
23
test_set_y_orig = test_set_y_orig.reshape((1, test_set_y_orig.shape[0]))
24
25
return train_set_x_orig, train_set_y_orig, test_set_x_orig, test_set_y_orig, classes
26
27
28