Skip to content

Commit 0cf1af0

Browse files
author
User
committedDec 13, 2022
update
1 parent 0b06cae commit 0cf1af0

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed
 

‎ann_logistic_extra/ann_train.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def predict(P_Y_given_X):
4848
def classification_rate(Y, P):
4949
return np.mean(Y == P)
5050

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)
5353

5454

5555
# train loop

‎ann_logistic_extra/logistic_softmax_train.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def predict(P_Y_given_X):
4444
def classification_rate(Y, P):
4545
return np.mean(Y == P)
4646

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)
4949

5050

5151
# train loop

‎ann_logistic_extra/process.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def get_data():
2121
# df.head()
2222

2323
# easier to work with numpy array
24-
data = df.values
24+
data = df.to_numpy()
2525

2626
# shuffle it
2727
np.random.shuffle(data)

0 commit comments

Comments
 (0)