Week 2, Neutral Network Basics
In this week’s material we learned about the basics of NNs. We learned how a logistic regression models work as well as how to implement them.
Programming Homework 2_2,
The alternatives of scipy.imread() and scipy.imresize():
In scipy1.3.1, imread and imresize is removed, so we need to use an alternative.
Most of the exsisting solutions focused on
pip install pillow
However this does not solve the problem since the function is removed, the PIL is not where the problem lies.
A working solution comes from here
In our specific case
import imageio
from PIL import Image
my_image = "maomao.jpg"
fname = "images/" + my_image
# imread() ORIGINALLY:
# image = scipy.misc.imread(fname)
# ALTERNATIVELY:
image = np.array(imageio.imread(fname))
# imresize() ORIGINALLY:
# my_image = scipy.misc.imresize(image, size=(num_px,num_px)).reshape((1, num_px*num_px*3)).T
# ALTERNATIVELY:
my_image = np.array(Image.fromarray(image).resize((num_px,num_px))).reshape((1, num_px*num_px*3)).T