ECS171 Winter 2024 Mid study guide-1
.pdf
keyboard_arrow_up
School
University of California, Davis *
*We aren’t endorsed by this school
Course
171
Subject
Computer Science
Date
Feb 20, 2024
Type
Pages
15
Uploaded by MagistrateTeam18466
ECS171 Winter 2024 Midterm Study Guide Cheat sheet Sigmoid and derivative of sigmoid:
࠵?(࠵?) =
1
1 + ࠵?
!"
࠵?′(࠵?) =
࠵?
࠵?࠵?
࠵?(࠵?) = ࠵?(࠵?)(1 − ࠵?(࠵?))
ReLU and Derivative for ReLU:
࠵?(࠵?) = ࠵?࠵?࠵?(0, ࠵?) = E
࠵?
࠵?࠵? ࠵? > 0,
0
࠵?࠵?ℎ࠵?࠵?࠵?࠵?࠵?࠵?.
࠵?′(࠵?) = O
1
࠵?࠵? ࠵? > 0,
0
࠵?࠵?ℎ࠵?࠵?࠵?࠵?࠵?࠵?,
Gradient descent weight update:
࠵?
#$%
= ࠵?
#
− ࠵? ⋅ ࠵?࠵?(࠵?
#
)
Errors:
࠵?࠵?࠵? =
1
࠵?
‘(࠵?
&
− ࠵?
’
b)
(
)
&*%
࠵?࠵?࠵? = ‘(࠵?
&
− ࠵?
’
b)
(
)
&*%
Variance:
࠵?࠵?࠵? = ࠵?
(
=
∑
(࠵?
&
− ࠵?̅)
(
)
&*%
࠵?
Chain Rule:
࠵?࠵? ℎ(࠵?) = ࠵?i࠵?(࠵?)k
ℎ
+
(࠵?) = ࠵?′(࠵?(࠵?)) ∙ ࠵?′(࠵?)
Performance Metrics:
࠵?࠵?࠵?࠵?࠵?࠵?࠵?࠵?࠵? =
࠵?࠵?
࠵?࠵? + ࠵?࠵?
࠵?࠵?࠵?࠵?࠵?࠵? (࠵?࠵?࠵?࠵? ࠵?࠵?࠵?࠵?࠵?࠵?࠵?࠵? ࠵?࠵?࠵?࠵?) =
࠵?࠵?
࠵?࠵? + ࠵?࠵?
࠵?
!
࠵?࠵?࠵?࠵?࠵? = 2 ∗
࠵?࠵?࠵?࠵?࠵?࠵?࠵?࠵?࠵? ∗ ࠵?࠵?࠵?࠵?࠵?࠵?
࠵?࠵?࠵?࠵?࠵?࠵?࠵?࠵?࠵? + ࠵?࠵?࠵?࠵?࠵?࠵?
࠵?࠵?࠵?࠵?࠵?࠵?࠵?࠵? =
࠵?࠵? + ࠵?࠵?
࠵?࠵? + ࠵?࠵? + ࠵?࠵? + ࠵?࠵?
(࠵?࠵?࠵?࠵? ࠵?࠵?࠵?࠵?࠵?࠵?࠵?࠵? ࠵?࠵?࠵?࠵?) ࠵?࠵?࠵? =
࠵?࠵?
࠵?࠵? + ࠵?࠵?
(࠵?࠵?࠵?࠵?࠵? ࠵?࠵?࠵?࠵?࠵?࠵?࠵?࠵? ࠵?࠵?࠵?࠵?) ࠵?࠵?࠵? =
࠵?࠵?
࠵?࠵? + ࠵?࠵?
Q1: In machine learning, what is the dropout technique, and how does it help prevent overfitting in neural networks? Answer: Dropout is a regularization technique in neural networks where during training, a random set of neurons are "dropped out" or turned off with a certain probability. This helps to prevent overfitting by making the network more robust and less reliant on specific neurons. For example, let's consider a neural network with dropout applied to a hidden layer. If the dropout rate is set to 0.5, during training, for each forward and backward pass, half of the neurons in that layer will be randomly deactivated. This means the network has to learn to be effective even when only a fraction of its neurons are active. This prevents the network from becoming overly specialized in recognizing patterns in the training data and helps it generalize better to unseen data. Q2: Given the hours of exercising per week measured in hours (
࠵?
!
) and time from last Covid-19 infection measured in weeks(
࠵?
"
), the model predicts the probability that the person will be re-
infected with Covid-19 in the next 5 months. The model follows the Linear Regression ŷ = 0.4 −
0.05࠵?
!
+ 0.07࠵?
"
, for each of the data pairs in the training and testing sets, do the following: (a) Compute the predicted output for the given regression model for each set of input (b) Compute the bias (SSE) for each set of inputs (c) Compute the variance. (d) Is the model overfit, underfit, or a good fit? Justify your answer using the following metrics for the base case: SSE_train = 0.050 SSE_test = 0.049 Variance = 0.01 Where needed, round your answer to 4 d.p. Training set: ࠵?
!
࠵?
"
࠵?
ŷ
(࠵? − ŷ)
"
0.0 4.0 0.70 3.0 10.0 0.95 2.0 3.0 0.60 5.0 1.0 0.15 8.0 5.5 0.25
12.0 7.5 0.23 10.0 4.0 0.20 3.0 2.0 0.30 Testing set: ࠵?
!
࠵?
"
࠵?
ŷ
(࠵? − ŷ)
"
1.0 9.0 0.95 9.0 6.0 0.20 7.0 3.0 0.25 5.0 5.0 0.45 Answer: Training set: ࠵?
!
࠵?
"
࠵?
ŷ
(࠵? − ŷ)
"
0.0 4.0 0.70 0.68 0.0004 3.0 10.0 0.95 0.95 0 2.0 3.0 0.60 0.51 0.0081 5.0 1.0 0.15 0.22 0.0049 8.0 5.5 0.25 0.385 0.0182 12.0 7.5 0.23 0.325 0.0009 10.0 4.0 0.20 0.18 0.0004 3.0 2.0 0.30 0.39 0.0081
Testing set: ࠵?
!
࠵?
"
࠵?
ŷ
(࠵? − ŷ)
"
1.0 9.0 0.95 0.98 0.0009 9.0 6.0 0.20 0.37 0.0289 7.0 3.0 0.25 0.26 0.0001 5.0 5.0 0.45 0.50 0.0025 SSE_train = sum of all (࠵? − ŷ)
"
= 0.041 SSE_test = sum of all (࠵? − ŷ)
"
= 0.0324 Variance = 0.041 - 0.0324 = 0.0086 Therefore the model is better fit compared to the base case. Q3: Find the coefficients of a polynomial with degree 2 which gives the lowest mean square error. y_predicted = ax^2 + bx + c x= [1,2,3] y_actual = [4, 13, 20] Coefficient Set 1: a= 1, b=2, c=3 Coefficient Set 2: a=3, b=5, c=2 Coefficient Set 3: a=1, b=1, c=5 Answer:
y_predicted = ax^2 + bx + c x= [1,2,3] y_actual = [4, 13, 20] Calculate the y_predicted for all 3 values of X for each coefficient set. For Coefficient set 1(a= 1, b=2, c=3): Y_predicted when x=1 is: 1*(1*1) + 2*1 + 3 = 6 Y_predicted when x=2 is: 1*(2*2) + 2*2 + 3 = 11 Y_predicted when x=3 is: 1*(3*3) + 2*3 + 3 = 18 MSE for coefficient set 1 = ((4-6)**2 + (13-11)**2 + (20-18)**2 )/3= 4 For Coefficient set 2(a=3, b=5, c=2): Y_predicted when x=1 is: 3*(1*1) + 5*1 + 2 = 10
Y_predicted when x=2 is: 3*(2*2) + 5*2 + 2 = 24 Y_predicted when x=3 is: 3*(3*3) + 5*3 + 2 = 44 MSE for coefficient set 2 = ((4-10)**2 + (13-24)**2 + (20-44)**2 )/3 = (36 + 121 + 484) / 3 = 213.66 For Coefficient set 3(a=1, b=1, c=5): Y_predicted when x=1 is: 1*(1*1) + 1*1 + 5 = 7 Y_predicted when x=2 is: 1*(2*2) + 1*2 + 5 = 11 Y_predicted when x=3 is: 1*(3*3) + 1*3 + 5 = 17 MSE for coefficient set 2 = ((4-7)**2 + (13-11)**2 + (20-17)**2 )/3 = (9 + 4 + 9) / 3 = 7.33 As we can see the lowest MSE is achieved for coefficient set 1. Therefore that is the best prediction of coefficients. Use the graph below to answer Q4-6:
Q4: If we designed this neural network with ReLU add after each hidden neural as activation function, and logistic(sigmoid) add in the end before we get the predicted value(y_hat), use the table below to calculate that which class does x1 = 7, x2 = 10, and x3 = 9 belongs. (Assume that as the result of one output has a value over a threshold τ = 0.9, it will be classified into that class.) W_1a = 0.4 W_a1=0.2 b_a=0.7 W_1b =-0.7 W_a2=0.5 b_b=0.4 W_2a=0.6 W_b1=-0.1 b_1=0.9 W_2b=-0.5 W_b2=0.6 b_2=-0.8 W_3a=0.3 W_3b=0.7 Answer: H_a = 7*0.4+10*0.6+9*0.3+0.7=12.2 H_b = 7*-0.7+10*-0.5+9*0.7+0.4=-3.2 O_1 = max(0,12.2)*0.2+max(0,-3.2)*-0.1+0.9=3.34 Y_hata = ࠵?
(O_1) = 1/(1+e^(-3.34)) = 0.9658 O_2 = max(0,12.2)*0.5+max(0,-3.2)*0.6+(-0.8)=5.3 Y_hatb = ࠵?
(O_2) = 1/(1+e^(-5.3)) = 0.9950 Therefore, this data point should belong to both category a and b. Q5: if the data points mentioned in Q7 have y_a= 1 and y_b = 0, update weight w_a1, w_a2, w_1a, and w_3a, consider the learning rate ࠵?
=0.2. Assume we use SSE for the loss of this question. Answer: ∂error/∂w_a1 = ∂error/∂y_hata*∂y_hata/∂O_1*∂O_1/∂w_a1
=-(y_a-y_hata)*y_hata*(1-y_hata)*max(0,H_a) = -(1-0.9658)*0.9658*(1-0.9658)*max(0,12.2) = -0.01378 W_a1new = 0.2-0.2*(-0.01378) =0.2027 ∂error/∂w_a2 = ∂error/∂y_hatb*∂y_hatb/∂O_2*∂O_2/∂w_a2
=-(y_b-y_hatb)*y_hatb*(1-y_hatb)*max(0,H_a) = -(0-0.9950)*0.9950*(1-0.9950)*max(0,12.2)
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
The IDS must be able to monitor itself and detect if it has been modified by an attacker.
Resist subversion
Fault tolerant
dynamic reconfiguration
adaptation
arrow_forward
at least 3 prameters
arrow_forward
Help
arrow_forward
sql injection code example to show vulnaribities and the mitigation to the vulnaribilites in java or python code
arrow_forward
An ATM allows a customer to withdraw a maximum of $500 per day. If a
customer withdraws more than $300, the service charge is 4% of the amount
over $300. If the customer does not have sufficient money in the account, the
ATM informs the customer about the insufficient fund and gives the option to
withdraw the money for a service charge of $25.00. If there is no money in the
account or if the account balance is negative, the ATM does not allow the
customer to withdraw any money. If the amount to be withdrawn is greater
than $500, the ATM informs the customer about the maximum amount that
can be withdrawn. Write an algorithm that allows the customer to enter the
amount to be withdrawn. The algorithm then checks the total amount in
the account, dispenses the money to the customer, and debits the account
by the amount withdrawn and the service charges, if any.
arrow_forward
i need the answer quickly
arrow_forward
course name : analysis alogrithm
arrow_forward
Please send
arrow_forward
An ATM allows a customer to withdraw a maximum of $500 per day. If a customer withdraws more than $300, the service charge is 4% of the amount over $300. If the customer does not have sufficient money in the account, the ATM informs the customer about the insufficient funds and gives the customer the option to withdraw the money for a service charge of $25.00. If there is no money in the account or if the account balance is negative, the ATM does not allow the customer to withdraw the money. If the amount to be withdrawn is greater than $500, the ATM informs the customer about the maximum amount that can be withdrawn and does not allow them to withdraw the money. Write an algorithm that allows the customer to enter the amount to be withdrawn. The algorithm then checks the total amount in the account, dispenses the money to the customer, and debits the account by the amount withdrawn and the service charges, if any.
arrow_forward
An ATM allows a customer to withdraw a maximum of $500 per day. If a customer withdraws more than $300, the service charge is 4% of the amount over $300. If the customer does not have sufficient money in the account, the ATM informs the customer about the insufficient funds and gives the customer the option to withdraw the money for a service charge of $25.00. If there is no money in the account or if the account balance is negative, the ATM does not allow the customer to withdraw any money. If the amount to be withdrawn is greater than $500, the ATM informs the customer about the maximum amount that can be withdrawn. Write an algorithm that allows the customer to enter the amount to be withdrawn. The algorithm then checks the total amount in the account, dispenses the money to the customer, and debits the account by the amount withdrawn and the service charges, if any. (9) Submit your answer to dropbox.
arrow_forward
The activation of one trigger may cause the activation of another.
True
False
arrow_forward
Testing for SQL-injection vulnerability: Suggest an approach for testing an application to find if it is vulnerable to SQL injection attacks on text input.
arrow_forward
The activation of one trigger may result in the activation of another trigger.
True
False
arrow_forward
Top-down security is better than bottom-up security.
arrow_forward
Written Use Case
Follow the sample format shown in the attached photo.Sample have its label, while the one you should make a written use case is the one who have blue ovals
arrow_forward
Explain the commandment number 8 in netiquette
arrow_forward
Lab Assignment 2: Playfair Cipher
Overview: You are required to use the Playfair cipher to encrypt the message: "Butch." You will
do the encryption by hand. The key for encryption is “Govern." You will need to show your work
for the encryption process. Your submission should be a typed text file
arrow_forward
Snort rules are broken into two logical sections or two groups of fields
(answer should be in lower case). What are the names given to each one of
these groups of snort fileds
Answer. First group of fields:
Answer. First group of fields:
arrow_forward
In the case of public key encryption, if you use both the signature and encryption features, which key will you use for encryption and which for signing?
arrow_forward
In MS Access, to ensure that a grade must be either A, B, C, D or F, whichvalidation rule should be used?A) ="A" or ="B" or ="C" or ="D" or ="F"B) between A and FC) like "A", "B", "C", "D", "F"D) not in ("A" or "B" or "C" or "D" or "F")E) in ("A", "B", "C", "D", "F")
arrow_forward
Before selecting a choice, consider all of the potential options to end a deadlock.
arrow_forward
The firing of one trigger can cause another trigger to fire.
True
False
arrow_forward
ObjectiveTo develop a simple database application using modern programming tools.ToolsStudents should use python as their main development platform. They can also choose either one of the database management systems SQLite, MySQL, PostgreSQL, and Microsoft SQL Server.GuidelinesEach student should agree to work with one student from the class as a teammate. Otherwise, the student works alone and gets penalized by getting at most 75% of the project grade. Teams should work independently toward the same project goal. Each team has to prepare a report presenting all the details about the work done and the job division. The number of pages should not pass twenty.Description of the ProjectThe project is to develop a simple university management system. The application should let three different kinds of users to work, namely, the student, the instructor, and the faculty coordinator. Users should have the following functionalities in the system:Faculty coordinator Log in to the system Add…
arrow_forward
Privilege users get different instructions.
arrow_forward
AITAM LIBRARY MANAGEMENT SYSTEM
AITAM Public Library is the biggest library in Koforidua. Currently, it has about 300 members. A person who is 18 or above can become a member. There is a membership fee of GHC400 for a year. There is a form to be filled in which person fills personal details. These forms are kept in store for maintaining members’ records and knowing the membership period.
A member can issue a maximum of three books. He/she has three cards to issue books. Against each card a member can issue one book from library. Whenever a member wishes to issue a book and there are spare cards, then the book is issued. Otherwise that request is not entertained. Each book is to be returned on the specified due date. If a member fails to return a book on the specified date, a fine of GHC 2 per day after the due return date is charged. In case a card gets lost, then a duplicate card is issued. Accounts are maintained for the membership fees and money collected from the fines.
There are…
arrow_forward
AITAM LIBRARY MANAGEMENT SYSTEM
AITAM Public Library is the biggest library in Koforidua. Currently, it has about 300 members. A person who is 18 or above can become a member. There is a membership fee of GHC400 for a year. There is a form to be filled in which person fills personal details. These forms are kept in store for maintaining members’ records and knowing the membership period.
A member can issue a maximum of three books. He/she has three cards to issue books. Against each card a member can issue one book from library. Whenever a member wishes to issue a book and there are spare cards, then the book is issued. Otherwise that request is not entertained. Each book is to be returned on the specified due date. If a member fails to return a book on the specified date, a fine of GHC 2 per day after the due return date is charged. In case a card gets lost, then a duplicate card is issued. Accounts are maintained for the membership fees and money collected from the fines.
There are…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
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
Related Questions
- sql injection code example to show vulnaribities and the mitigation to the vulnaribilites in java or python codearrow_forwardAn ATM allows a customer to withdraw a maximum of $500 per day. If a customer withdraws more than $300, the service charge is 4% of the amount over $300. If the customer does not have sufficient money in the account, the ATM informs the customer about the insufficient fund and gives the option to withdraw the money for a service charge of $25.00. If there is no money in the account or if the account balance is negative, the ATM does not allow the customer to withdraw any money. If the amount to be withdrawn is greater than $500, the ATM informs the customer about the maximum amount that can be withdrawn. Write an algorithm that allows the customer to enter the amount to be withdrawn. The algorithm then checks the total amount in the account, dispenses the money to the customer, and debits the account by the amount withdrawn and the service charges, if any.arrow_forwardi need the answer quicklyarrow_forward
- course name : analysis alogrithmarrow_forwardPlease sendarrow_forwardAn ATM allows a customer to withdraw a maximum of $500 per day. If a customer withdraws more than $300, the service charge is 4% of the amount over $300. If the customer does not have sufficient money in the account, the ATM informs the customer about the insufficient funds and gives the customer the option to withdraw the money for a service charge of $25.00. If there is no money in the account or if the account balance is negative, the ATM does not allow the customer to withdraw the money. If the amount to be withdrawn is greater than $500, the ATM informs the customer about the maximum amount that can be withdrawn and does not allow them to withdraw the money. Write an algorithm that allows the customer to enter the amount to be withdrawn. The algorithm then checks the total amount in the account, dispenses the money to the customer, and debits the account by the amount withdrawn and the service charges, if any.arrow_forward
- An ATM allows a customer to withdraw a maximum of $500 per day. If a customer withdraws more than $300, the service charge is 4% of the amount over $300. If the customer does not have sufficient money in the account, the ATM informs the customer about the insufficient funds and gives the customer the option to withdraw the money for a service charge of $25.00. If there is no money in the account or if the account balance is negative, the ATM does not allow the customer to withdraw any money. If the amount to be withdrawn is greater than $500, the ATM informs the customer about the maximum amount that can be withdrawn. Write an algorithm that allows the customer to enter the amount to be withdrawn. The algorithm then checks the total amount in the account, dispenses the money to the customer, and debits the account by the amount withdrawn and the service charges, if any. (9) Submit your answer to dropbox.arrow_forwardThe activation of one trigger may cause the activation of another. True Falsearrow_forwardTesting for SQL-injection vulnerability: Suggest an approach for testing an application to find if it is vulnerable to SQL injection attacks on text input.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
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