by yuan meng
X: [1, 0, 1, 1]
not "pulling punches" 👉 set to around 0
X: [1, 1, 0, 1]
likely negative
👉 < - (w1 + w4)
likely positive
👉 > w1 + w4
class label: 0
class label: 1
class label: 0
class label: 1
class label: 0
🥳
used in hw5
# dimension of all images
DIM = (28, 28)
# flattened imahe
N = DIM[0] * DIM[1]
def load_image_files(n, path="images/"):
"""loads images of given digit and returns a list of vectors"""
# initialize empty list to collect vectors
images = []
# read files in the path
for f in sorted(os.listdir(os.path.join(path, str(n)))):
p = os.path.join(path, str(n), f)
if os.path.isfile(p):
i = np.loadtxt(p)
# check image dimension
assert i.shape == DIM
# flatten i into a single vector
images.append(i.flatten())
return images
# load images of '0' and '1'
img1 = load_image_files(0)
img0 = load_image_files(1)
1brown3blue author on working w/ images (in julia, but well explained)
arr2d: name of your 2d numpy array
arr1d: name of your 1d numpy array
two numpy arrays of same length
array to plot (q3: weights; q5: accuracies)
dimension of target 2d array