3

While building a simple neural net for reading digits, I was getting this warning: RuntimeWarning:

C:\anaconda\lib\site-packages\ipykernel_launcher.py:4: RuntimeWarning: 
overflow encountered in square
after removing the cwd from sys.path.

Googeling it revealed nothing of importance on the meaning and solution of it. Will anyone care to explain ?

enter image description here

Here is some of the code, if it helps:

w1_2 = np.random.rand(784,10)/100
w2_3 = np.random.rand(10,10)/100
w3_4 = np.random.rand(10,10)/100
b2 = np.random.rand(10)/100
b3 = np.random.rand(10)/100
b4 = np.random.rand(10)/100

for gd_up in range(1000):
    b2gd = []
    b3gd = []
    b4gd = []
    w12gd = []
    w23gd = []
    w34gd = []
    c = []
    for pic,pic_ca in zip(digits_train,digits_train_ca):
        b2,b3,b4,w12,w23,w34 = get_GD(pic,int(pic_ca))
        b2gd.append(b2)  
        b3gd.append(b3)
        b4gd.append(b4)
        w12gd.append(w12)
        w23gd.append(w23)
        w34gd.append(w34)
        c.append(get_c(feedforward(pic),int(pic_ca)))
    b2_f = sum(b2gd)/len(b2gd)
    b3_f = sum(b3gd)/len(b3gd)
    b4_f = sum(b4gd)/len(b4gd)
    w12_f = sum(w12gd)/len(w12gd)
    w23_f = sum(w23gd)/len(w23gd)
    w34_f = sum(w34gd)/len(w34gd)
    b2 = b2-(0.01*b2_f)
    b3 = b3-(0.01*b3_f)
    b4 = b4-(0.01*b4_f)
    w1_2 = w1_2-(0.01*w12_f)
    w2_3 = w2_3-(0.01*w23_f)
    w3_4 = w3_4-(0.01*w34_f)
    print(np.mean(c))
Moran Reznik
  • 1,201
  • 2
  • 11
  • 28
  • Is `after removing the cwd from sys.path.` actually part of the output you received? – user2357112 Dec 01 '17 at 17:36
  • That *is* line 4 of `ipykernel_launcher.py`, but it doesn't make sense for that message to come from that line. – user2357112 Dec 01 '17 at 17:40
  • @user2357112 added a picture of the error – Moran Reznik Dec 01 '17 at 17:40
  • Can you tell us which line exactly raises the error? Otherwise, an `overflow` is usually raised when computing too big numbers, like for instance if you tried to do the `square` of a very large number. See also this [SO question](https://stackoverflow.com/questions/45402988/python-huge-exponentiation-gets-stuck-but-doesnt-raise-an-error/45403067#45403067) maybe. – Arthur Spoon Dec 01 '17 at 17:54
  • @ArthurSpoon how can I know which line coused the error? the error messege do not specify it. – Moran Reznik Dec 01 '17 at 17:57
  • @מורןרזניק if you run it from a terminal or even just the basic Python interpreter it should give you the error with a line number. Not too familiar with `ipykernel`. – Arthur Spoon Dec 01 '17 at 18:00

0 Answers0