aburkov / theMLbook

The Python code to reproduce the illustrations from The Hundred-Page Machine Learning Book.

Home Page:http://themlbook.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failed in running gradient_descent.py.

geyang78 opened this issue · comments

Hello, I have installed all the Software Libraries required, and removed the header (the first line of Advertising.csv), removed the ids (the first column of Advertising.csv), and then replaced the comas by tabs (real tabs, not 2/4/8 spaces). However, I still failed in running it.
PS C:\Users\DELL> & C:/Users/DELL/AppData/Local/Programs/Python/Python36/python.exe "e:/Work/2020-Summer/other/Research Project/Report/ML/from future import print_function.py"
epoch: 0 loss: 92.32078294903626
w, b: 0.7412639000000002 0.028045000000000007
Traceback (most recent call last):
File "e:/Work/2020-Summer/other/Research Project/Report/ML/from future import print_function.py", line 74, in
w, b = train(x, y, 0.0, 0.0, 0.001, 15000)
File "e:/Work/2020-Summer/other/Research Project/Report/ML/from future import print_function.py", line 60, in train
fig1.savefig('../../Illustrations/gradient_descent-' + str(image_counter) + '.eps', format='eps', dpi=1000, bbox_inches = 'tight', pad_inches = 0)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\figure.py", line 2203, in savefig
self.canvas.print_figure(fname, **kwargs)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\backend_bases.py", line 2126, in print_figure
**kwargs)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\backends\backend_ps.py", line 831, in print_eps
return self._print_ps(outfile, 'eps', *args, **kwargs)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\backends\backend_ps.py", line 851, in _print_ps
orientation, papertype, **kwargs)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\cbook\deprecation.py", line 358, in wrapper
return func(*args, **kwargs)
File "C:\Users\DELL\AppData\Local\Programs\Python\Python36\lib\site-packages\matplotlib\backends\backend_ps.py", line 1076, in _print_figure
with open(outfile, 'w', encoding='latin-1') as fh:
FileNotFoundError: [Errno 2] No such file or directory: '../../Illustrations/gradient_descent-2.eps'
PS C:\Users\DELL>
How to solve this problem.
Thank you very much.

You possibly just need to create the Illustrations folder two levels above the current working directory, indicated by ../../Illustrations/ so the plots can be saved.

FileNotFoundError: [Errno 2] No such file or directory: '../../Illustrations/gradient_descent-2.eps'