Course 1, how to run assignments locally

Hi,

I would like to run all assignments of Course 1 “Neural Networks and Deep Learning” , weeks 1 to 4, locally on my machine in order to be able to use some own data, etc. - How can I achieve this? I have exported the *.ipynb files together with the other files used in their import section to a local directory, but when I try to run an assignment on my local Jupyter Notebook installation, I get this:

--------------------------------------------------------------------------- ValueError Traceback (most recent call last) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\axes_axes.py in _parse_scatter_color_args (c, edgecolors, kwargs, xshape, yshape, get_next_color_func) 4283 try : # Then is ‘c’ acceptable as PathCollection facecolors? → 4284 colors = mcolors . to_rgba_array ( c ) 4285 n_elem = colors . shape [ 0 ] ~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\colors.py in to_rgba_array (c, alpha) 293 for i , cc in enumerate ( c ) : → 294 result [ i ] = to_rgba ( cc , alpha ) 295 return result ~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\colors.py in to_rgba (c, alpha) 176 if rgba is None : # Suppress exception chaining of cache lookup failure. → 177 rgba = _to_rgba_no_colorcycle ( c , alpha ) 178 try : ~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\colors.py in _to_rgba_no_colorcycle (c, alpha) 243 if len ( c ) not in [ 3 , 4 ] : → 244 raise ValueError ( “RGBA sequence should have length 3 or 4” ) 245 if len ( c ) == 3 and alpha is None : ValueError : RGBA sequence should have length 3 or 4 During handling of the above exception, another exception occurred: ValueError Traceback (most recent call last) in 1 # Visualize the data: ----> 2 plt . scatter ( X [ 0 , : ] , X [ 1 , : ] , c = Y , s = 40 , cmap = plt . cm . Spectral ) ; ~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\pyplot.py in scatter **(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, plotnonfinite, data, kwargs) 2846 verts = verts , edgecolors = edgecolors , 2847 plotnonfinite=plotnonfinite, **({“data”: data} if data is not → 2848 None else {}), kwargs) 2849 sci ( __ret ) 2850 return _ret **~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib_init.py in inner **(ax, data, *args, kwargs) 1597 def inner ( ax , ***** args , data = None , ****** kwargs ) : 1598 if data is None : → 1599 return func ( ax , ***** map ( sanitize_sequence , args ) , ****** kwargs ) 1600 1601 bound = new_sig . bind ( ax , ***** args , ****** kwargs ) ~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\axes_axes.py in scatter **(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, plotnonfinite, kwargs) 4451 self._parse_scatter_color_args( 4452 c , edgecolors , kwargs , xshape , yshape , → 4453 get_next_color_func=self._get_patches_for_fill.get_next_color) 4454 4455 if plotnonfinite and colors is None : ~\AppData\Local\Continuum\anaconda3\lib\site-packages\matplotlib\axes_axes.py in _parse_scatter_color_args (c, edgecolors, kwargs, xshape, yshape, get_next_color_func) 4295 "acceptable for use with ‘x’ with size {xs}, " 4296 “‘y’ with size {ys}.” → 4297 . format ( nc = n_elem , xs = xsize , ys = ysize ) 4298 ) 4299 else : ValueError : ‘c’ argument has 1 elements, which is not acceptable for use with ‘x’ with size 400, ‘y’ with size 400.

Thanks for your effort in advance.

Best regards,
Dan

If you want to execute the notebook with your own data you have several options:

  1. The easiest one would be to open the notebook in Google Colab, you would need to install the missing packages (if any) using pip or conda commands. The main advantage is that most of the packages would be available and that you could use a GPU if needed.
  2. Another option would be to setup a local Anaconda environment, there you would need to install all required packages.
    I don’t know what you mean with “I have exported the *.ipynb files together with the other files used in their import section”, I guess you are expected to install the packages either using conda commands or pip to ensure you have all required dependencies.

Thanks for your reply. I already ave Anaconda and run Jupyter Notebook from there. i have uploaded the exported Jupyyter notebook of week 3 into it and also these *.py files:

planar_utils.py
public_tests.py
test_utils.py
testCases_v2.py

However, when I try to run cell 4 of this notebook locally then I get errors:

plt.scatter(X[0, :], X[1, :], c=Y, s=40, cmap=plt.cm.Spectral);


ValueError Traceback (most recent call last)
d:\Anaconda3\lib\site-packages\matplotlib\axes_axes.py in _parse_scatter_color_args(c, edgecolors, kwargs, xshape, yshape, get_next_color_func)
4283 try: # Then is ‘c’ acceptable as PathCollection facecolors?
→ 4284 colors = mcolors.to_rgba_array(c)
4285 n_elem = colors.shape[0]

d:\Anaconda3\lib\site-packages\matplotlib\colors.py in to_rgba_array(c, alpha)
293 for i, cc in enumerate(c):
→ 294 result[i] = to_rgba(cc, alpha)
295 return result

d:\Anaconda3\lib\site-packages\matplotlib\colors.py in to_rgba(c, alpha)
176 if rgba is None: # Suppress exception chaining of cache lookup failure.
→ 177 rgba = _to_rgba_no_colorcycle(c, alpha)
178 try:

d:\Anaconda3\lib\site-packages\matplotlib\colors.py in _to_rgba_no_colorcycle(c, alpha)
243 if len(c) not in [3, 4]:
→ 244 raise ValueError(“RGBA sequence should have length 3 or 4”)
245 if len(c) == 3 and alpha is None:

ValueError: RGBA sequence should have length 3 or 4

During handling of the above exception, another exception occurred:

ValueError Traceback (most recent call last)
in
1 # Visualize the data:
----> 2 plt.scatter(X[0, :], X[1, :], c=Y, s=40, cmap=plt.cm.Spectral);

d:\Anaconda3\lib\site-packages\matplotlib\pyplot.py in scatter(x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, plotnonfinite, data, **kwargs)
2846 verts=verts, edgecolors=edgecolors,
2847 plotnonfinite=plotnonfinite, **({“data”: data} if data is not
→ 2848 None else {}), **kwargs)
2849 sci(__ret)
2850 return __ret

d:\Anaconda3\lib\site-packages\matplotlib_init_.py in inner(ax, data, *args, **kwargs)
1597 def inner(ax, *args, data=None, **kwargs):
1598 if data is None:
→ 1599 return func(ax, *map(sanitize_sequence, args), **kwargs)
1600
1601 bound = new_sig.bind(ax, *args, **kwargs)

d:\Anaconda3\lib\site-packages\matplotlib\axes_axes.py in scatter(self, x, y, s, c, marker, cmap, norm, vmin, vmax, alpha, linewidths, verts, edgecolors, plotnonfinite, **kwargs)
4451 self._parse_scatter_color_args(
4452 c, edgecolors, kwargs, xshape, yshape,
→ 4453 get_next_color_func=self._get_patches_for_fill.get_next_color)
4454
4455 if plotnonfinite and colors is None:

d:\Anaconda3\lib\site-packages\matplotlib\axes_axes.py in _parse_scatter_color_args(c, edgecolors, kwargs, xshape, yshape, get_next_color_func)
4295 "acceptable for use with ‘x’ with size {xs}, "
4296 “‘y’ with size {ys}.”
→ 4297 .format(nc=n_elem, xs=xsize, ys=ysize)
4298 )
4299 else:

ValueError: ‘c’ argument has 1 elements, which is not acceptable for use with ‘x’ with size 400, ‘y’ with size 400.

How can this be fixed?

Thanks for your help.

Best regards,
Dan

Hi,

I was able o get rid of most errors by updating Anaconda, especially the sklearn packages. The only on left is:

Train the logistic regression classifier

clf = sklearn.linear_model.LogisticRegressionCV();

clf.fit(X.T, Y.T);

d:\Anaconda3\lib\site-packages\sklearn\utils\validation.py:63: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
return f(*args, **kwargs)

Any idea?

Thanks and best regards,
Dan