File tree 3 files changed +5
-5
lines changed
3 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,8 @@ def predict(P_Y_given_X):
48
48
def classification_rate (Y , P ):
49
49
return np .mean (Y == P )
50
50
51
- def cross_entropy (T , pY ):
52
- return - np .mean ( T * np .log (pY ))
51
+ def cross_entropy (Y , pY ):
52
+ return - np .sum ( Y * np .log (pY )) / len ( T )
53
53
54
54
55
55
# train loop
Original file line number Diff line number Diff line change @@ -44,8 +44,8 @@ def predict(P_Y_given_X):
44
44
def classification_rate (Y , P ):
45
45
return np .mean (Y == P )
46
46
47
- def cross_entropy (T , pY ):
48
- return - np .mean ( T * np .log (pY ))
47
+ def cross_entropy (Y , pY ):
48
+ return - np .sum ( Y * np .log (pY )) / len ( Y )
49
49
50
50
51
51
# train loop
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ def get_data():
21
21
# df.head()
22
22
23
23
# easier to work with numpy array
24
- data = df .values
24
+ data = df .to_numpy ()
25
25
26
26
# shuffle it
27
27
np .random .shuffle (data )
You can’t perform that action at this time.
0 commit comments