Prev: L25, Next: L27

Zoom: Link, Piazza: Link, Google Form: Link.

Wisc ID for in-class quiz: (if your wisc email is "test@wisc.edu", please enter "test")
Token: (will be given during the lectures)



# Warning: this is a draft and will be updated one day before the lecture.


Slide:



# Genetic Algorithm

📗 Genetic algorithm starts with a fixed population of initial states, and the successors are found through cross-over and mutation: Wikipedia.
📗 Each state in the population with \(N\) states has probability of reproduction proportional to the fitness (or negatively proportional to the costs): \(p_{i} = \dfrac{f\left(s_{i}\right)}{f\left(s_{1}\right) + f\left(s_{2}\right) + ... + f\left(s_{N}\right)}\).
📗 If the states are encoded by strings, cross-over means swapping substrings at a fixed point: for example, abcde and ABCDE cross-over at position 2 results in abCDE and ABcde: Wikipedia.
📗 If the states are encoded by strings, mutation means randomly updating substrings with a small probability called the mutation rate: for example, abcde can be updated to abCde or aBcDe or ... with small probabilities: Link
📗 Genetic algorithm: in each generation, the reproduction process is:
➩ Randomly sample two states based on the reproduction probabilities.
➩ Cross-over these two states to produce two children states.
➩ Mutate these two states with small probabilities.
➩ Repeat the process until the same population size is reached, and continue to the next generation.
In-class Quiz (Past Exam Question) ID:
📗 [4 points] When using the Genetic Algorithm, suppose the states are \(\begin{bmatrix} x_{1} & x_{2} & ... & x_{T} \end{bmatrix}\) = , , , . Let \(T\) = , the fitness function (not the cost) is \(\mathop{\mathrm{argmax}}_{t \in \left\{0, ..., T\right\}} x_{t} = 1\) with \(x_{0} = 1\) (i.e. the index of the last feature that is 1). What is the reproduction probability of the first state: ?
📗 Answer: .




# Variants of Genetic Algorithm

📗 The parents do not survive in the standard genetic algorithm, but if reproduction between two copies of the same state is allowed, the parents can survive.
📗 The fitness or cost functions can be replaced by the ranking.
➩ If state \(s_{i}\) has the \(k\)-th lowest fitness value among all states, the reproduction probability can be computed by \(p_{i} = \dfrac{k}{1 + 2 + ... + N}\).
📗 In theory, cross-over is much more efficient than mutation.
Example
📗 Many problems can be solved by genetic algorithm (but in practice, reinforcement learning techniques are more efficient and produce better policies).
➩ Walkers: Link.
➩ Cars: Link.
➩ Eaters: Link.
➩ Image: Link.



# State Representation of Neural Networks

📗 A neural network can be represented by a sequence of weights (a single state).
📗 Two neural networks can swap a subset of weights (cross-over).
📗 One neural network can randomly update a subset of weights with small probability (mutation).
📗 Genetic algorithm can be used to train neural networks to perform reinforcement learning tasks.
Example
📗 Flappy bird: Link, Link.
📗 Cars: Link.




# Dual Use of AI

📗 Drug discovery: flip the objective function to make optimization find many highly toxic compounds: Link (drug discovery), PDF (toxic chemical).
📗 Image generation: deepfake (fake videos and face images): Wikipedia, Link (this person does not exist), Link (2024 election).
📗 Robotics: Wikipedia, Link (autonomous weapons), Link (UW Robotics).



# AI Ethics

📗 Bias and fairness: Link (fairness and bias), PDF (gender bias), PDF (racial bias).
➩ Collect representative data from minority groups.
➩ Remove bias associations
➩ Add fairness constraints to the optimization problem for learning.
📗 Fake content
📗 Privacy: Link (Netflix de-anonymization attack), Link (social network)
➩ Right to be forgotten (deep networks need to unlearn)
➩ Differential privacy (done by adding noise to dataset)
📗 Adversarial robustness: Link (turtle or rifle), Link (black box attack), Link (LLM attack), Link (Trojan/Backdoor attack), Link (YOLO test time attack).
➩ Training time attack (fake training data)
➩ Test time attack (adversarial training to defend)
📗 Value alignment: Link (value alignment).
📗 Other recommended readings:
➩ Weapons of Math Destruction: Wikipedia
➩ Concrete Problems in AI Safetfy: PDF
➩ On the Dangers of Stochastic Parrots: Link




# Questions?

📗 If you have questions, please use (i) Zoom chat, (ii) Piazza: Link, (iii) Office hours and discussion sessions. Please do NOT use Canvas mail and use email only to the course instructor (not TAs) for grading issues.
Additional In-class Discussion
📗 Sometimes a question not in the notes will be asked during the lecture, you can submit your answer here:

Notes (not visible to other students):


Submit your answer to see other students answers (click the submit button to refresh): 

Additional In-class Quiz
📗 Sometimes a question not in the notes will be asked during the lecture, you can submit your answer here:
A.
B.
C.
D.
E.
Notes (not visible to other students):


Submit your answer to see other students answers (click the submit button to refresh): 






# In-class Quiz Instructions

📗 To get full points on the in-class quizzes for a lecture:
➩ Submit relevant answers to the questions discussed during the lecture: incorrect answers are okay.
➩ Some questions require [notes] to earn the point.
➩ Some questions require special ID (given during the lecture) to earn the point.
➩ Do not submit answers to questions that are not discussed during the lectures. Each such submission will result in a deduction of one point.
➩ Submissions after the lecture, before the midterm (first 14 lectures) and the final exam (last 14 lectures), are accepted. After the exams, no in-class quiz submissions will be accepted.
➩ The grade on Canvas Assignment Q26 is computed as number of points divided by the number of questions asked (out of 1) and updated on Canvas every weekend.
📗 If there are any issues with submission on the website, please use this Google form: Link.
📗 Bonus point opportunities during a few lectures (added to in-class quiz above 20 points).
📗 Notes and code adapted from the course taught by Professors Jerry Zhu, Blerina Gkotse, Yudong Chen, Yingyu Liang, Charles Dyer. Some content are generated using Copilot .

Prev: L25, Next: L27





Last Updated: June 26, 2026 at 3:06 AM