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 generator_function(): | |
| value = 1 | |
| print("This is printed first") | |
| yield value | |
| value += 1 | |
| print("This is printed second") | |
| yield value | |
| value += 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
| class HashTable(object): | |
| def __init__(self): | |
| self.max_length = 8 | |
| self.max_load_factor = 0.75 | |
| self.length = 0 | |
| self.table = [None] * self.max_length | |
| def __len__(self): | |
| return self.length |
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
| len = size(theta); | |
| J = 1/m*(-y'*log(sigmoid(X*theta))-(1-y)'*log(1-sigmoid(X*theta))) + lambda/(2*m)*sum(theta(2:len).^2); | |
| grad = 1./m*((sigmoid(X*theta)-y)'*X); | |
| temp = theta; | |
| temp(1) = 0; | |
| grad = grad + (lambda/m.*temp)'; |