C2_W3 lab 1 regression with perceptron - getting errors in last 2 cells of notebook

For Lab 1 on Week 3 lesson, the last 2 cells do not work.

I’m curious what’s causing the errors. If anyone has any input, that would be great.

I’ll post the output from the 2nd to lass cell, as follows

Cost after iteration 0: 52.266244 Cost after iteration 1: 6618981604291.577148 Cost after iteration 2: 846311471320470990618624.000000 Cost after iteration 3: 108210469420893299308137172653047808.000000 Cost after iteration 4: 13835929311013779144529656932128475018176757760.000000 Cost after iteration 5: 1769079654897125725509824906218896586152823055154765889536.000000 Cost after iteration 6: 226196792063664255953444515045859427095075340782741852969582393819136.000000 Cost after iteration 7: 28921811744462000693345678811150428750502542905319308608479570967967141074042880.000000 Cost after iteration 8: 3697979918064755730176009978235555431475248818595978506953219145832505792148579018738761728.000000 Cost after iteration 9: 472828451939174924920610230981618489130268219301079419917897520981823527514645707850688758651608367104.000000 Cost after iteration 10: 60456451878244564605821746663568506663790292264482551752138490570877500303416798215138904522360351018568837496832.000000 Cost after iteration 11: 7730039422789816545984888130326765086967213359832275486969429668771922728284266946700785286974916843997565157732608450232320.000000 Cost after iteration 12: 988372748010824415195284112606517260118663772624364736264398210019064745550498806116158647390877141058145072971701469575912467761987584.000000 Cost after iteration 13: 126374606335178003155460615955806224976119246052393092500097543292807413493154879367074914251877919411362561883332168713458881434455643480674795520.000000 Cost after iteration 14: 16158419137428784382974668008903429211638450177389094809518827781966792105051724812031062368310066685995162288690552752669278493340237628130179080428546162688.000000 Cost after iteration 15: 2066036180784094798111994747530806505213313711163688240493063795812354884882849964893390460031075892472204897813364832850088209216493009700765476946022185410462419517440.000000 Cost after iteration 16: 264166034065889919475141390987863126846969885086296330353974284944194718518213314554961634669827875905178279676214307937956352857473822945089888350934826010682049225072622312620032.000000 Cost after iteration 17: 33776607691166716765181803830901502611844394736122293335650644067510478716538099008302142626017966174380542447082796831167010462639256007257404034928469688821726896900557299120430799631941632.000000 Cost after iteration 18: 4318720350090210236186399335009697045714922030336896427164791599128581101716000791225915141750821562868926470026669127428802151371671670981465704626674611970133815278499473824295912743748132581744312320.000000 Cost after iteration 19: 552197119166618822874781108141605537300039161801396630425261886819105677212649035251714227081691574615505711677176531038235177638276715541722092930923877799767935428166182109153963921769837305226100290121057173504.000000 Cost after iteration 20: 70604631394932596148751182492024971188038950827369120380980452157594069854160974975380709323315209726058948495759233428729221271556198227830068305699555803974958206382508623930797771770422725124969903397848055681627700854784.000000 Cost after iteration 21: 9027598662480742134014685565554641095959393930943821523429930090382958433409873675177033306666220265297278816277335307556772745184910384207481395631176198547891355074626334387469511412746994976329649124298893942823183455534274878373888.000000 Cost after iteration 22: 1154280335449403631787422261827858095939315847103147174979150774783748553852505454567989684438328912729151225752401195329115319312692959434618816526193133371648999467503271524596884761506471676975712169511109022465775398657228712396301784389255168.000000 Cost after iteration 23: 147587763104995776776963996065055508374753344444321258347027846562098046303782978650852259798856514624482181832080291838738243278943710383203886809153366423061877758422888238402069140448328077565663561226944085774630419164191297659659577729846157711645868032.000000 Cost after iteration 24: 18870760550430583666271109720848685161547939032369924269064848967769469003918749361096502650005125783800710397400246400875070818013326594197805931282591625986213168075390446351099762691162684176902434506616014378984839327351845082587262161570745310964734508392251392000.000000 Cost after iteration 25: 2412839630195826208923813406354280042328394738454908075561441008712058127169265848730321648246377799673584364367483026033431438457417764686990285704989679410776691551034809593928648051277226507590133843045103459431670484999548148644039142014140727926060805332103010692887117561856.000000 Cost after iteration 26: 308508767597640347347571477170566057779743286794388709230333678285986946485110806834908917902194027101034723701197911351681653715886065032874117106858304565232150776400509781715693414388463301795347799736885941179826114512530884930679784780164828842951165986782896093343244033240728382472192.000000 Cost after iteration 27: 39446326433593273220577897435973243263266510951184300676970607758621599675181406515282310970649282700056449895858244049326959615835419832240592158019345199011559577014879557279796653035284830965622160596244782763047697834164177897489085164273374333775807997649147665034839503957247895272672172936527872.000000 Cost after iteration 28: inf Cost after iteration 29: inf Cost after iteration 30: inf Cost after iteration 31: inf Cost after iteration 32: inf Cost after iteration 33: inf Cost after iteration 34: inf Cost after iteration 35: inf Cost after iteration 36: inf Cost after iteration 37: inf Cost after iteration 38: inf Cost after iteration 39: inf Cost after iteration 40: inf Cost after iteration 41: inf Cost after iteration 42: inf Cost after iteration 43: inf Cost after iteration 44: inf Cost after iteration 45: inf Cost after iteration 46: inf Cost after iteration 47: inf Cost after iteration 48: inf Cost after iteration 49: inf Cost after iteration 50: inf Cost after iteration 51: inf Cost after iteration 52: inf Cost after iteration 53: inf Cost after iteration 54: inf Cost after iteration 55: inf Cost after iteration 56: nan Cost after iteration 57: nan Cost after iteration 58: nan Cost after iteration 59: nan Cost after iteration 60: nan Cost after iteration 61: nan Cost after iteration 62: nan Cost after iteration 63: nan Cost after iteration 64: nan Cost after iteration 65: nan Cost after iteration 66: nan Cost after iteration 67: nan Cost after iteration 68: nan Cost after iteration 69: nan Cost after iteration 70: nan Cost after iteration 71: nan Cost after iteration 72: nan Cost after iteration 73: nan Cost after iteration 74: nan Cost after iteration 75: nan Cost after iteration 76: nan Cost after iteration 77: nan Cost after iteration 78: nan Cost after iteration 79: nan Cost after iteration 80: nan Cost after iteration 81: nan Cost after iteration 82: nan Cost after iteration 83: nan Cost after iteration 84: nan Cost after iteration 85: nan Cost after iteration 86: nan Cost after iteration 87: nan Cost after iteration 88: nan Cost after iteration 89: nan Cost after iteration 90: nan Cost after iteration 91: nan Cost after iteration 92: nan Cost after iteration 93: nan Cost after iteration 94: nan Cost after iteration 95: nan Cost after iteration 96: nan Cost after iteration 97: nan Cost after iteration 98: nan Cost after iteration 99: nan W = [[nan nan]] b = [[nan]]

/var/folders/f1/dmgdbt5j5nb5ht5_vfxmr8gm0000gn/T/ipykernel_21833/651274294.py:17: RuntimeWarning: overflow encountered in square cost = np.sum((Y_hat - Y)**2)/(2*m) /Users/danherman/miniconda3/envs/tf/lib/python3.11/site-packages/numpy/core/fromnumeric.py:86: RuntimeWarning: overflow encountered in reduce return ufunc.reduce(obj, axis, dtype, out, **passkwargs) /var/folders/f1/dmgdbt5j5nb5ht5_vfxmr8gm0000gn/T/ipykernel_21833/583824931.py:14: RuntimeWarning: invalid value encountered in matmul Z = np.matmul(W, X) + b

1 Like

It worked fine for me. There was no code we needed to modify in this “assignment”: it’s just a demonstration, right? Are you sure you didn’t accidentally (or purposefully) modify anything?

1 Like

A screen capture image would be more helpful.

Note that you can do the “Get Latest Version” procedure documented here. I just did that and the only change in the last month or so was to upgrade to a new version of python, but it still works fine, as shown above.

My guess is that you have damaged the notebook somehow. Try getting a clean copy and I’ll bet the problem goes away.

2 Likes

Can you confirm the codes for the issue being mentioned is recalled correctly??

I was running the notebook locally when the error persisted

When I run the notebook from the lab, it works fine

There appears to be issues running the notebook locally. I like to keep the notebooks locally for reference purposes after I complete the course.

Is there a known issue with running this particular notebook locally? This is the 2nd specialization I’ve taken with deeplearning.ai, all the notebooks worked fine locally until this point.

PS - I did not change any of the code and I did refresh the notebooks in the lab to ensure I have the correct version.

Thanks for your help.

1 Like

No, I have not previously heard that about this specific assignment, but it is the case that
we have seen other instances in which “versionitis” of the various packages (everything from python to matplotlib to TensorFlow) causes problems, when running locally or in some other environment (e.g. Colab). There are ways to duplicate environments: here’s a thread which will get you started down that path. It’s not a complete recipe, but this is pretty complicated stuff and it’s hard to anticipate all possible problems on all the variety of environments.

2 Likes

I just asked if there is a known issue. If the answer is no, then you answered my question.

1 Like