This file contains hidden or 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 csv | |
ZIP_CODE_FILE_NAME = 'zips.csv' | |
COVERAGE_PLAN_FILE_NAME = 'plans.csv' | |
SLCSP_FILE_NAME = 'slcsp.csv' | |
SLCSP_OUTPUT_FILE_NAME = 'slcsp_answer.csv' | |
PLAN_TYPE = 'Silver' |
This file contains hidden or 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 torch | |
import torch.nn as nn | |
import torch.optim as optim | |
from torch.optim import lr_scheduler | |
import numpy as np | |
import time | |
import os | |
import argparse | |
## Load the model |
This file contains hidden or 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
def compute_cost(Al, Y): | |
""" | |
Arguments: | |
AL -- probability vector corresponding to your label predictions, shape (1, number of examples) | |
Y -- true "label" vector (for example: containing 0 if non-cat, 1 if cat), shape (1, number of examples) | |
Returns: | |
cost -- cross-entropy cost | |
""" |
This file contains hidden or 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
def linear_activation_forward(W,A_prev,b, activation): | |
""" | |
Implement the linear part of a layer's forward propagation. | |
Arguments: | |
A_prev -- activations from previous layer (or input data): (size of previous layer, number of examples) | |
W -- weights matrix: numpy array of shape (size of current layer, size of previous layer) | |
b -- bias vector, numpy array of shape (size of the current layer, 1) |
This file contains hidden or 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
def linear_forward(W,A,b): | |
""" | |
Implement the linear part of a layer's forward propagation. | |
Arguments: | |
A -- activations from previous layer (or input data): (size of previous layer, number of examples) | |
W -- weights matrix: numpy array of shape (size of current layer, size of previous layer) | |
b -- bias vector, numpy array of shape (size of the current layer, 1) | |
Returns: | |
Z -- the input of the activation function, also called pre-activation parameter | |
cache -- a python dictionary containing "A", "W" and "b" ; stored for computing the backward pass efficiently |
This file contains hidden or 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
def initialize_parameters(layer_dims): | |
"""" | |
INPUTS: | |
layers_dim: represents the dimension of each hidden layer in the neural network, the index(i) represents the | |
layer while layers_dim[i] represents the number of nodes in that layer | |
RETURN: | |
this should return intialized paramenters from W1, b1 to Wl-1, bl-1 assuming l = length of layers_dim | |
where Wi is of shape (L[i], L[i-1]) |
This file contains hidden or 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 | |
def load_data(): | |
train_dataset = h5py.File('./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('./test_catvnoncat.h5', "r") |
This file contains hidden or 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 math # This will import math module | |
class KNearestNeighbor(object): | |
""" a kNN classifier with L2 distance """ | |
def __init__(self): | |
pass |