Skip to content

Instantly share code, notes, and snippets.

View Tooluloope's full-sized avatar
💭
Still busy

Tolulope Adetula Tooluloope

💭
Still busy
View GitHub Profile
@Tooluloope
Tooluloope / slcsp.py
Created July 3, 2019 08:16
Ad Hoc Home work
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'
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
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
"""
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)
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
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])
@Tooluloope
Tooluloope / loaddata.py
Created March 12, 2019 06:15
Numpy from scratch
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")
@Tooluloope
Tooluloope / knn.py
Created January 23, 2019 15:16
Knn.py
import numpy as np
import math # This will import math module
class KNearestNeighbor(object):
""" a kNN classifier with L2 distance """
def __init__(self):
pass