-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublic_tests.py
85 lines (73 loc) · 2.19 KB
/
public_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import numpy as np
from dlai_tools.testing_utils import single_test, multiple_test
def forward_propagation_test(target):
x, theta = 2, 4
expected_output = 8
test_cases = [
{
"name": "equation_output_check",
"input": [x, theta],
"expected": expected_output,
"error": "Wrong output"
}
]
single_test(test_cases, target)
def backward_propagation_test(target):
x, theta = 3, 4
expected_output = 3
test_cases = [
{
"name": "equation_output_check",
"input": [x, theta],
"expected": expected_output,
"error": "Wrong output"
}
]
single_test(test_cases, target)
def gradient_check_test(target):
x, theta = 3, 4
expected_output = 7.814075313343006e-11
test_cases = [
{
"name": "equation_output_check",
"input": [x, theta],
"expected": expected_output,
"error": "Wrong output"
}
]
single_test(test_cases, target)
def predict_test(target):
np.random.seed(1)
X = np.random.randn(2, 3)
parameters = {'W1': np.array([[-0.00615039, 0.0169021 ],
[-0.02311792, 0.03137121],
[-0.0169217 , -0.01752545],
[ 0.00935436, -0.05018221]]),
'W2': np.array([[-0.0104319 , -0.04019007, 0.01607211, 0.04440255]]),
'b1': np.array([[ -8.97523455e-07],
[ 8.15562092e-06],
[ 6.04810633e-07],
[ -2.54560700e-06]]),
'b2': np.array([[ 9.14954378e-05]])}
expected_output = np.array([[True, False, True]])
test_cases = [
{
"name":"datatype_check",
"input": [parameters, X],
"expected": expected_output,
"error":"Data type mismatch"
},
{
"name": "shape_check",
"input": [parameters, X],
"expected": expected_output,
"error": "Wrong shape"
},
{
"name": "equation_output_check",
"input": [parameters, X],
"expected": expected_output,
"error": "Wrong output"
}
]
single_test(test_cases, target)