This file contains 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
NotesArchiver-AP-Lab |
This file contains 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
package Crawler; | |
/** | |
* Created by Sanitarium on 3/4/2016. | |
*/ | |
import java.util.*; | |
public class WorkQueue { | |
// |
This file contains 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
package CoinChange; | |
import java.util.ArrayList; | |
import java.util.Iterator; | |
import java.util.TreeSet; | |
/** | |
* Created by Sanitarium on 4/15/2016. | |
*/ |
This file contains 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
package Interpreter; | |
/** | |
* Created by Sanitarium on 4/29/2016. | |
*/ | |
import javafx.util.Pair; | |
import java.io.*; | |
import java.*; |
This file contains 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 numpy library | |
class SigmoidLayer: | |
""" | |
This file implements activation layers | |
inline with a computational graph model | |
Args: | |
shape: shape of input to the layer |
This file contains 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 | |
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 |
This file contains 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(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: |
This file contains 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
# 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) |
This file contains 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
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) |
This file contains 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_bce_cost(Y, P_hat): | |
""" | |
This function computes Binary Cross-Entropy(bce) Cost and returns the Cost and its | |
derivative. | |
This function uses the following Binary Cross-Entropy Cost defined as: | |
=> (1/m) * np.sum(-Y*np.log(P_hat) - (1-Y)*np.log(1-P_hat)) | |
Args: | |
Y: labels of data | |
P_hat: Estimated output probabilities from the last layer, the output layer |
OlderNewer