
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
Write a Python program for applying CNN with considering the following requirements:
- Shuffle the cifar 10 training set x_train( each input with corresponding label in y_train )
- Select 2500 images and you must ensure that each class must contain at least 180 samples
- Apply CNN that keeps noisy examples. Overall, the pseudocode of CNN is as follows:
- The code must contain at least one lambda expression
- The code must contain at one comprehension list
- It is Not allowed to use the numpy library.
Euclidean distance is the distance between two samples in Euclidean space. The formula can be expressed as:
![+ X Python Tryit Editor
W X Python Tryit Editor
W X Python Operators
X Answered: You rece b
X CSC 605_HW1 - Jup E
X Downloads/csc/
f
localhost:8888/notebooks/Downloads/csc/CSC%20605_HW1.ipynb#2)-Convert-the-following-function-to-lambda-expression O
->
قائمة القراءة
SQL for Beginners:. û
B مرحبّار فياض - . .Black
Google hiljs A
YouTube
Gmail M
التطبيقات
قائمة القراءة
Cjupyter CSC .•_HW' Last Checkpoint: ácll io uual (autosaved)
Logout
File
Edit
View
Insert
Cell
Kernel
Widgets
Help
Python 3 O
Not Trusted
+
Run
Markdown
Condensed Nearest Neighbor (CNN)
Data reduction techniques aim to simplify the training data by removing noisy and redundant data, so that, machine learning algorithms can learn faster with
little or no performance degradation, as if the entire training set T is used.
CNN was the first data reduction Algorithm. This algorithm is an incremental method that starts with adding one example of each class to the subset S
randomly from training set T. Then, for each example x in T is classified using the examples in S. if the example x is incorrectly classified, it will be added to
S. This guarantees all instances in T are classified correctly. Based on this criterion, noisy examples will be retained because they are commonly classified
wrongly by their k – NN (whrere k = 1)
The CIFAR-10 dataset The CIFAR-10 dataset consists of 60000 32x32 colour images in 10 classes, with 6000 images per class. There are 50000 training
images and 10000 test images.
In order to load CIFAR-10 dataset, First, download tensorflow library using the following command:
install tensorflow
Then, use the following code:
In [63]: import tensorflow
import cv2
from tensorflow import keras
from PIL import Image
import numpy as p
(x_train, y_train), (_, _) = tf.keras.datasets.cifar10.load_data()
x_train = [cv2.cvtColor(image, cv2.COLOR_BGR2GRAY).flatten().tolist() for image in x_train]
##x_train=np.asarray(x_train)
print(len(x_train))
print(len(x_train[0])) # 32*32
<IPython.core.display.Javascript object>
50000
1024
3:03 PM
O Type here to search
96°F
O C 1) ENG
9/27/2021
()](https://content.bartleby.com/qna-images/question/723158fd-7202-4703-8c7a-3adefb105dcc/a98a63c1-5664-4458-a809-739892cb86f4/x86kc6u_thumbnail.png)
Transcribed Image Text:+ X Python Tryit Editor
W X Python Tryit Editor
W X Python Operators
X Answered: You rece b
X CSC 605_HW1 - Jup E
X Downloads/csc/
f
localhost:8888/notebooks/Downloads/csc/CSC%20605_HW1.ipynb#2)-Convert-the-following-function-to-lambda-expression O
->
قائمة القراءة
SQL for Beginners:. û
B مرحبّار فياض - . .Black
Google hiljs A
YouTube
Gmail M
التطبيقات
قائمة القراءة
Cjupyter CSC .•_HW' Last Checkpoint: ácll io uual (autosaved)
Logout
File
Edit
View
Insert
Cell
Kernel
Widgets
Help
Python 3 O
Not Trusted
+
Run
Markdown
Condensed Nearest Neighbor (CNN)
Data reduction techniques aim to simplify the training data by removing noisy and redundant data, so that, machine learning algorithms can learn faster with
little or no performance degradation, as if the entire training set T is used.
CNN was the first data reduction Algorithm. This algorithm is an incremental method that starts with adding one example of each class to the subset S
randomly from training set T. Then, for each example x in T is classified using the examples in S. if the example x is incorrectly classified, it will be added to
S. This guarantees all instances in T are classified correctly. Based on this criterion, noisy examples will be retained because they are commonly classified
wrongly by their k – NN (whrere k = 1)
The CIFAR-10 dataset The CIFAR-10 dataset consists of 60000 32x32 colour images in 10 classes, with 6000 images per class. There are 50000 training
images and 10000 test images.
In order to load CIFAR-10 dataset, First, download tensorflow library using the following command:
install tensorflow
Then, use the following code:
In [63]: import tensorflow
import cv2
from tensorflow import keras
from PIL import Image
import numpy as p
(x_train, y_train), (_, _) = tf.keras.datasets.cifar10.load_data()
x_train = [cv2.cvtColor(image, cv2.COLOR_BGR2GRAY).flatten().tolist() for image in x_train]
##x_train=np.asarray(x_train)
print(len(x_train))
print(len(x_train[0])) # 32*32
<IPython.core.display.Javascript object>
50000
1024
3:03 PM
O Type here to search
96°F
O C 1) ENG
9/27/2021
()

Transcribed Image Text:+ X Python Tryit Editor
W X Python Tryit Editor
W X Python Operators
X Answered: You rece b
X CSC 605_HW1 - Jup E
X Downloads/csc/
f
localhost:8888/notebooks/Downloads/csc/CSC%20605_HW1.ipynb#2)-Convert-the-following-function-to-lambda-expression O
->
قائمة القراءة
SQL for Beginners:. û
B مرحبّار فياض - . .Black
Google hiljs A
YouTube
Gmail M
التطبيقات
Cjupyter CSC 1.•_HW) Last Checkpoint:r ácldl io uual (autosaved)
Logout
Widgets
Python 3 O
File
Edit
View
Insert
Cell
Kernel
Help
Not Trusted
+
Run
Markdown
1024
Write a Python program for applying CNN with considering the following requirements:
• Shuffle the cifar 10 training set x_train( each input with corresponding label in y_train )
• Select 2500 images and you must ensure that each class must contain at least 180 samples
• Apply CNN that keeps noisy examples. Overall, the pseudocode of CNN is as follows:
PROCEDURE CNN(S,D,Z)
BEGIN
Z := {};
REPEAT
additions:=FALSE;
FOR all patterns in the training set DO
Randomly pick æ from training set, S
Find z. E Z such that D(x, zc) = min; D(x, z;)
IF class(x) # class(zc) THEN
Z := Z U x;
additions:=TRUE
END IF
3:06 PM
O Type here to search
96°F
O G ») ENG
9/27/2021
()
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps with 1 images

Knowledge Booster
Similar questions
- write the following usong for loopsarrow_forwardCount divisibles in range def count_divisibles_in_range(start, end, n): Let us take a breather by tackling a problem simple enough that its solution needs only a couple of conditional statements and some arithmetic, but not even one loop or anything even more fancy. The difficulty is coming up with the conditions that cover all possible cases of this problem exactly right, including all of the potentially tricksy edge and corner cases, without being off-by-one. Given three integers start, end and n so that start <= end, count how many integers between start and end, inclusive, are divisible by n. Sure, you could solve this problem with the list comprehension one-linerreturn len([x for x in range(start, end+1) if x % n == 0]) but of course the automated tester is designed so that anybody trying to solve this problem in such a blunt fashion will only find themselves running out of both time and space! Your code should have no loops at all, but use only integer arithmetic and…arrow_forwardArtificial Intelligence (Part - 2) ==================== The Towers of Hanoi is a famous problem for studying recursion incomputer science and searching in artificial intelligence. We start with N discs of varying sizes on a peg (stacked in order according to size), and two empty pegs. We are allowed to move a disc from one peg to another, but we are never allowed to move a larger disc on top of a smaller disc. The goal is to move all the discs to the rightmost peg (see figure). To solve the problem by using search methods, we need first formulate the problem. Supposing there are K pegs and N disk. (2) What is the size of the state space?arrow_forward
- Pythonarrow_forwardWrite a Python program for applying CNN with considering the following requirements: Shuffle the cifar 10 training set x_train( each input with corresponding label in y_train ) Select 2500 images and you must ensure that each class must contain at least 180 samples Apply CNN that keeps noisy examples. Overall, the pseudocode of CNN is as follows: The code must contain at least one lambda expression The code must contain at one comprehension list It is Not allowed to use the numpy library. Euclidean distance is the distance between two samples in Euclidean space. The formula can be expressed as: USE THIS CODE import tensorflowimport cv2from tensorflow import kerasfrom PIL import Imageimport numpy as p (x_train, y_train), (_, _) = tf.keras.datasets.cifar10.load_data() x_train = [cv2.cvtColor(image, cv2.COLOR_BGR2GRAY).flatten().tolist() for image in x_train]##x_train=np.asarray(x_train)print(len(x_train))print(len(x_train[0])) # 32*32 NOTE: PLEAS USE THE CODE I ATTACHED NOTE 2:…arrow_forwardArtificial Intelligence (Part - 1) ==================== The Towers of Hanoi is a famous problem for studying recursion in computer science and searching in artificial intelligence. We start with N discs of varying sizes on a peg (stacked in order according to size), and two empty pegs. We are allowed to move a disc from one peg to another, but we are never allowed to move a larger disc on top of a smaller disc. The goal is to move all the discs to the rightmost peg (see figure). To solve the problem by using search methods, we need first formulate the problem. Supposing there are K pegs and N disk. (1) Propose a state representation for the problem?arrow_forward
- In Python the only import that may be used is Numpy Implement a function called page_rank which will take as input a numpy array M, which will represent the transition matrix of a directed graph, and a positive integer n. The output will be a numpy array which gives the page ranks of each vertex in the graph represented by M. You will iterate the update process n times.arrow_forwardIn C++ language. Sample run should be exact as the one on image. Thanksarrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education

Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education