I'm new to using the math
library in Python. The purpose of this script is to show my "working out" of Cross-Entropy
error function.
I have checked my parentheses and operators and cannot see anything wrong, with my noob eyes.
The error occurs on the last line.
out = 1.099
target = 0.7
do = 3
print('CEE = -(log(' + str(out) + ') + ((1 - ' + str(target) + ') * log(1 - ' + str(out) + ')))')
print(' = -(log(' + str(out) + ') + ((' + str(round(1 - target, dp)) + ') * log(' + str(round(1 - out, dp)) + ')))')
print(' = -(' + str(round(m.log(out), dp)) + ' + ((' + str(round(1 - target, dp)) + ') * ' + str(round(m.log(1 - out), dp)) + '))')
Output & Error:
CEE = -(log(1.099) + ((1 - 0.7) * log(1 - 1.099)))
= -(log(1.099) + ((0.3) * log(-0.099)))
Traceback (most recent call last):
File "main.py", line 3, in <module>
import Perceptron
File "/home/runner/Deep-Learning/Perceptron.py", line 125, in <module>
print(' = -(' + str(round(m.log(out), dp)) + ' + ((' + str(round(1 - target, dp)) + ') * ' + str(round(m.log(1 - out), dp)) + '))')
ValueError: math domain error