Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1) Classifying handwritten digits: Using the MNIST dataset, we will build a simple threshold-based classifier that classifies 0 digits from non-0s. a) Create a

Problem 1) Classifying handwritten digits: Using the MNIST dataset, we will build a simple threshold-based classifier that classifies 0 digits from non-0s. a) Create a new training, validation and test set as you did in problem 3 of Assignment 1, but this time include only the 0 and 1 digits. Hint: From the test set select only 0s and 1s. Repeat this for the training set. Then, create a validation set as done in the previous assignment. b) Convert each image to one attribute by calculating the average of all the pixel values in the center 3x3 grid of the image. c) Randomly select 500 of the images from the training data. Plot their attribute values that you calculated in part (b). Use different colors and shapes for 0s and 1s. The x axis in your figure is the image number (1 to 500) and y axis is the calculated attribute. Label the axes and add legends appropriately. Note that these 500 images are your validation set. Problem 3 from Assignment 1:

from keras.datasets import mnist import matplotlib.pyplot as plt import numpy as np from random import randint

(x_train, y_train), (x_test, y_test) = mnist.load_data() image text in transcribed This is what I have so far, but I need to select all 1's and 0's not just 4.

#Selecting O's and I's from training set print('selecting zeros and ones from training set') x_train_rnd=np.zeros((10,x_train.shape[1],x_train.shape[2])) y_train_rnd=np.arange (10) for digit in range (2): x_train_d=x_train[y_train=-digit,:,:] x_train_rnd[digit,:,:]=x_train_d[randint(0,x_train_d.shape[0]),:,:] img_plt(x_train_rnd,y_train_rnd) print('selecting zeros and ones from testing set') x_test_rnd=np.zeros((10,x_test. shape[1],x_test. shape[2])) y_test_rnd=np.arange (10) for digit in range(2) : x_test_d=x_test[y_test=digit,:,:] x_test_rnd[digit, :,:]=x_test_d[randint(0,x_test_d.shape[0]),:,:] img_plt(x_test_rnd,y_test_rnd) #Selecting O's and I's from training set print('selecting zeros and ones from training set') x_train_rnd=np.zeros((10,x_train.shape[1],x_train.shape[2])) y_train_rnd=np.arange (10) for digit in range (2): x_train_d=x_train[y_train=-digit,:,:] x_train_rnd[digit,:,:]=x_train_d[randint(0,x_train_d.shape[0]),:,:] img_plt(x_train_rnd,y_train_rnd) print('selecting zeros and ones from testing set') x_test_rnd=np.zeros((10,x_test. shape[1],x_test. shape[2])) y_test_rnd=np.arange (10) for digit in range(2) : x_test_d=x_test[y_test=digit,:,:] x_test_rnd[digit, :,:]=x_test_d[randint(0,x_test_d.shape[0]),:,:] img_plt(x_test_rnd,y_test_rnd)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions

Question

8-6 Who poses the biggest security threat: insiders or outsiders?

Answered: 1 week ago