def linear_backward(dZ, cache): """ Implement the linear portion of backward propagation for a single layer (layer l) Arguments: dZ -- Gradient of the cost with respect to the linear output (of current layer l) cache -- tuple of values (A_prev, W, b) coming from the forward propagation in the current layer Returns: dA_prev -- Gradient of the cost with respect to the activation (of the previous layer l-1), same shape as A_prev dW -- Gradient of the cost with respect to W (current layer l), same shape as W db -- Gradient of the cost with respect to b (current layer l), same shape as b """ A_prev, W, b = cache m = A_prev.shape[1] dW = (1./m)*(np.dot(dZ,A_prev.T)) db = (1./m)*(np.sum(dZ, axis=1, keepdims=1)) dA_prev = np.dot(W.T, dZ) assert (dA_prev.shape == A_prev.shape) assert (dW.shape == W.shape) assert (db.shape == b.shape) return dA_prev, dW, db
def find_total_abs_deviation(self, cols=None): if cols is None: eval_set_df = self.features_df else: eval_set_df = self.features_df.loc[:, cols] departure_time = self.find_departure_time(eval_set_df) actual_arrivals = eval_set_df.loc[eval_set_df.index == departure_time, :].values total_deviation = np.sum(np.abs(actual_arrivals)) return total_deviation, departure_time
def test_sum_pos(self): data = [3,4] result = sum(data) self.assertEqual(result, 7)
def test_sum_largenums(self): data = [4738494329,7529383821] result = sum(data) self.assertEqual(result, 12267878150)
def test_sum_none(self): data = [] result = sum(data) self.assertEqual(result, 0)
def test_sum_value_missing(self): data = [3] result = sum(data) self.assertEqual(result, 3)
def test_sum_zero(self): data = [0,4] result = sum(data) self.assertEqual(result, 4)
def test_sum_pos_neg(self): data = [-3,4] result = sum(data) self.assertEqual(result, 1)
def test_sum_neg(self): data = [-3,-4] result = sum(data) self.assertEqual(result, -7)
"16": "odd_even", "17": "Postive_Negative", "18": "Exit" } while True: print('\n\nAvailable functions in numbers:\n\n', Numberdict) import numbers Number_Input = input( "\n\nSelect any one number to perform the operation:") if Number_Input == "1": print("\n\n UserGuide : Sum function used to Add Two Values") Sum_Input = int(input("\nEnter the first value:")) Sum_Input1 = int(input("Enter the second value:")) print("The Sum of Given value :", numbers.sum(Sum_Input, Sum_Input1)) elif Number_Input == "2": print( "\n\n UserGuide : Sub function used to subtract Two Values" ) Sub_Input = int(input("\nEnter the first value:")) Sub_Input1 = int(input("Enter the second value:")) print("The Sub output of Given value :", numbers.sub(Sub_Input, Sub_Input1)) elif Number_Input == "3": print( "\n\n UserGuide : mul function used to multiply Two Values" ) Mul_Input = int(input("\nEnter the first value:")) Mul_Input1 = int(input("Enter the second value:")) print("The mul output of Given value :",
choice = int(input("Enter your choice:")) if choice == 1 : print("1. Sum of numbers") print("2. Difference of two numbers") print("3. Product of numbers") print("4. Power of numbers") print("5. Square root of a number") print("6. Cuberoot of a number") print("7. Factorial of number") print("8. Table of a number") pick = int(input("Please enter your choice:")) if pick == 1: numbers.sum() elif pick == 2: numbers.difference() elif pick == 3: numbers.product() elif pick == 4: numbers.power() elif pick == 5: numbers.squareroot() elif pick == 6: numbers.cuberoot() elif pick == 7: numbers.factorial() elif pick == 8: numbers.printTable()