Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

RafayAK RafayAK

🎯
Focusing
View GitHub Profile
View src_java_Crawler_WorkQueue.java
package Crawler;
/**
* Created by Sanitarium on 3/4/2016.
*/
import java.util.*;
public class WorkQueue {
//
View src_java_CoinChange_Dynamic.java
package CoinChange;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.TreeSet;
/**
* Created by Sanitarium on 4/15/2016.
*/
View java_Interpreter_Interpret.java
package Interpreter;
/**
* Created by Sanitarium on 4/29/2016.
*/
import javafx.util.Pair;
import java.io.*;
import java.*;
@RafayAK
RafayAK / ActivationLayer.py
Created Jun 19, 2019
Class for Sigmoid Activation Layer
View ActivationLayer.py
import numpy as np # import numpy library
class SigmoidLayer:
"""
This file implements activation layers
inline with a computational graph model
Args:
shape: shape of input to the layer
@RafayAK
RafayAK / paramInitializer.py
Created Jun 19, 2019
Helper function to initialize weights and biases
View paramInitializer.py
import numpy as np
def initialize_parameters(n_in, n_out, ini_type='plain'):
"""
Helper function to initialize some form of random weights and Zero biases
Args:
n_in: size of input layer
n_out: size of output/number of neurons
ini_type: set initialization type for weights
@RafayAK
RafayAK / compte_cost.py
Last active Jun 20, 2019
This helper function computes the squared error cost and its derivative
View compte_cost.py
def compute_cost(Y, Y_hat):
"""
This function computes and returns the Cost and its derivative.
The is function uses the Squared Error Cost function -> (1/2m)*sum(Y - Y_hat)^.2
Args:
Y: labels of data
Y_hat: Predictions(activations) from a last layer, the output layer
Returns:
@RafayAK
RafayAK / defining_layers.py
Last active Jun 20, 2019
Defining a 2 layer neural net
View defining_layers.py
# define training constants
learning_rate = 1
number_of_epochs = 5000
np.random.seed(48) # set seed value so that the results are reproduceable
# (weights will now be initailzaed to the same pseudo-random numbers, each time)
# Our network architecture has the shape:
# (input)--> [Linear->Sigmoid] -> [Linear->Sigmoid] -->(output)
@RafayAK
RafayAK / training_loop.py
Created Jun 20, 2019
The main training loop for 2-layer nn
View training_loop.py
costs = [] # initially empty list, this will store all the costs after a certian number of epochs
# Start training
for epoch in range(number_of_epochs):
# ------------------------- forward-prop -------------------------
Z1.forward(X_train)
A1.forward(Z1.Z)
Z2.forward(A1.A)
@RafayAK
RafayAK / LinearLayer.py
Last active Jun 21, 2019
Class for Linear Layer
View LinearLayer.py
import numpy as np # import numpy library
from util.paramInitializer import initialize_parameters # import function to initialize weights and biases
class LinearLayer:
"""
This Class implements all functions to be executed by a linear layer
in a computational graph
Args:
You can’t perform that action at this time.