0% found this document useful (0 votes)
13 views

Week01 Intro AI

Uploaded by

bobforlife001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Week01 Intro AI

Uploaded by

bobforlife001
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Lectures 1 and 2 – MECH 4403

Artificial Intelligence and


Generative Design for
Mechanical Systems

Mehdi Ataei, Alidad Amirfazli


The Objectives
• Explore the core concepts and applications of Artificial Intelligence
(AI)
• Learn Python, the primary language for Machine Learning (ML), and
how to develop, train, and integrate AI models into your workflows
• Gain insight into generative AI models and their practical applications
Why learn about AI when I can just use it?
• Even if you’re not planning to be an “AI expert”, grasping the
underlying mechanics of AI demystifies the technology
• Given the current trends, regardless of your future work, AI will be
most likely a part of your workflow (or your work will be influenced
by it)
• AI models are not magical black boxes. Understanding their inner
workings leads to more effective usage and better problem-solving
• An understanding of AI fundamentals equips you with the skills to
innovate, troubleshoot, and excel in the field
Why AI Became Successful?
• AI and machine learning are empowered by the data explosion and
increased compute power
AI vs. ML/DL

edureka.co
How to think about ML models
• One can think of a machine learning model as a mapping
between input and output
• Our goal is to find the model that best maps the input to our
desired output
Machine Learning

Input Model Output


How to think about ML models
• In ML, finding the best map is achieved “training” a model on a
vast amount of data

Machine Learning

Input Model Output


Importance of Data
• Imagine we have collected data for the prediction of temperature per
day

• What models can we fit this data?


• Linear?
• Non-linear?
More Data
• 400 Datapoints reveals that our
previous fits were incorrect!
• When the problem becomes multi-
dimensional, finding the best model is
even more challenging
• For example, temperature prediction
can be a function of season, solar
radiation, time of day, altitude, wind
speed, and many more parameters
More Data Needs Better Models
• This is where ML comes handy
• It allows us to use learn and predict using very complex models to
find the “ground truth”
ML inputs/outputs
Recall
• Key Questions:
• What are the inputs?
• Data features: variables or attributes used to make predictions
• Examples: images, text, sensor data, customer information
• What are the outputs?
• Predicted values or categories based on the input
• Examples: class labels, continuous values, decisions

Machine Learning

Input Model Output


Data Representation in ML (inputs and
outputs)
• Machines only understand numerical values! Therefore, all data
types, including text and categorical variables, must be transformed
into numerical format.
• Machines have no notion what “cat”, ”dog”, “car” mean! either as a
category of items, or as text!
• The numerical output generated by the machine learning model must
be easily interpretable and serve our purpose!
ML Inputs – Tabular data
• ML, “tabular data” refers to data that is organized into tables, much like what you'd see in a spreadsheet or a
relational database.
• Each row in the table represents a unique sample or observation, and each column represents a specific
feature or attribute of that instance. One of the columns may also represent the target variable that the
machine learning model aims to predict.

Inputs (features) target


ML Inputs – Images
• An image is represented as a grid of pixels.
• Each pixel has one or more color channels, typically Red, Green, and Blue (RGB) in color images, or just a
single channel in grayscale images.
• Each color channel of a pixel stores a numeric value, usually ranging from 0 to 255, indicating the intensity of
that color.
• The dimensions of the image are defined by the number of pixels along its width and height. For example, a
640x480 image has 640 pixels along its width and 480 along its height.
• In computer programming, an image is often represented as a multi-dimensional array. For a grayscale
image, this would be a 2D array, while for an RGB image, it would typically be a 3D array.
Screen under Microscope
• Screens work under the same principle!
• RGB (Red, Green, Blue): Screens combine
these colors to display images.
• Pixels: Each pixel has red, green, and blue
subpixels.
• Color Mixing: Varying subpixel intensity
creates different colors (e.g., white = full
RGB).
ML Inputs – Text data
• Text data must be converted into numerical format for compatibility
with ML algorithms.
• Numerical Representation Methods:
1.Statistical Features
1. Utilize measures like word frequency and text length to represent the data.
2.Tokenization
1. Convert text into unique integer values called tokens.
Word Tokenization
• Word tokenization involves splitting a piece of text into individual
words, treating each word as a separate entity or token
• Consider the sentence: "Hello World! Hello Everyone!”
• Each unique word or token is then associated with a unique
numerical identifier. "Hello" is 1, "World" is 2, "Everyone" is 3, "!" is 4
(as a dictionary).
• Numerical representation: [1,2,4,1,3,4]
This is How ChatGPT works!
• https://platform.openai.com/tokenizer
• Note that this is “subword” tokenization
Statistical Approach for Text Representation
• Let's consider a simple example involving movie reviews. Suppose we
want to classify reviews as either “Positive” or “Negative”.
• By counting the frequency of words in each review, we create a
numerical representation of the text.
• Words like “amazing,” “excellent,” and “great” may appear more
frequently in positive reviews, while words like “boring,” “bad,”” and
“terrible” may appear more frequently in negative reviews.
• Therefore, we may be able to represent our text data using its
statistics instead of raw tokens
Using Statistics to Represent Text

['and' 'document' 'first' 'is' 'one' 'second' 'the' 'third' 'this']


[[0 1 1 1 0 0 1 0 1]
Count of each word [0 2 0 1 0 1 1 0 1]
[1 0 0 1 1 0 1 1 1]
ML Output = Goal
• Imagine the goal of classifying an image
into three categories (“dog”, “cat”,
“chicken”)
• Categories are referred to “Classes” in ML
lingo
• We already learnt that the input of the
ML model can be an image (represented
by its RGB values)
How do you think the output should look like?
ML Outputs
• When we talk about the output of our machine learning model, we
are essentially talking about the model's end goal
• The way the output is formatted must correspond with what we aim
to achieve with the model
• The output is not just an end result; it embodies what we initially set
out to accomplish with our machine learning model
Machine Learning

Input Model Output


ML Outputs – Probabilities
• Range of Values: These probabilities dog
are real numbers that lie in the 0.92

interval [0, 1]
• A higher probability for a class
suggests a stronger confidence that
cat
the input belongs to that class. For 0.06
example, a 0.9 probability for 'Cat'
means the model is quite confident
that the input image is of a cat chicken
0.02

How to convert probabilities to class labels?


Choose the label with the highest probability!
ML Outputs – Probabilities
dog
0.47

cat
0.02

chicken
0.51
ML Outputs – Real Numbers
• In many ML models, the outputs can be
real numbers rather than probabilities
• Unlike classification, where the output is
a label or category, the output in
regression is a real number that can
range from negative to positive infinity.
• Useful in regression problems:
• Predicting housing prices
• Predicting temperature
ML Outputs – Integer values
• Semantic segmentation involves classifying each pixel in an image to a
specific category, essentially "labeling" parts of the image
• Each integer value corresponds to a specific category or class that a
pixel belongs to. For example, in a mask for segmenting a road scene,
pixels corresponding to "road" might be labeled as 1, "car" as 2,
"pedestrian" as 3, and so on.

https://blog.research.google/2020/07/improving-holistic-scene-understanding.html?m=1
ML Outputs – Same as the Input!
• Input is text, output is also text!

Cats walk quietly at


night, listen to them
Large Language Model meow.
write a song about cats.
(ChatGPT) Their whiskers move,
under the moon, they
know just how.
ML Outputs – Images
• Text to image
RGB array!

Diffusion Model (image


A chair design inspired by retro games
generator)
Do We Always Need ML?
Scenario:
Imagine you are collecting data on the types of fruit your friends like the most. You ask 4 friends and
each one tells you their favorite fruit.
Data:
1. Friend #1: Apple
2. Friend #2: Banana
3. Friend #3: Orange
4. Friend #4: Apple
• Phenomenon: Favorite fruits among friends
• Classes: Apple, Banana, Orange (3 types of fruit)
Why We Need for Machine Learning for this task?
Why No Need for Machine Learning?
• Limited Cases: We only have 3 types of fruit
• Simple to Understand: It is easy to see what each friend likes
• Summary: We can simply make a table to understand this for all cases!

Favorite Fruit Number of Friends


Apple 2
Banana 1
Orange 1

• For such simple data, simple statistical analysis can be done to understand
it e.g., the most favorable fruit
Spam Emails
Scenario: Detecting spam emails
Dataset:
You have 100 emails. Out of these, 20 are spam and 80 are not spam.

Complexity:
You know that spam emails can have countless forms and messages
that you haven't seen yet.

Do we need ML in this case? Why?


Generalization
• Machine learning becomes necessary when we can only obtain a
small number of samples from a phenomenon, and we know that
these samples are just a small subset of the phenomenon.
• Therefore, we need a model for the phenomenon that accounts for
the samples that we have not yet encountered.
• For example, we need the ability to predict how the system will
behave when given novel inputs for which we do not have data.
Why Machine Learning?
• Limited Samples: You only have 100 emails as your data sample,
which is not enough to cover all types of spam.
• Unencountered Samples: You haven't seen all possible types of spam
emails that could appear in the future.
• Need for Prediction: You want your email system to filter out future
spam that you haven't encountered yet.

ML task: Understand the patterns in your 100 email samples


ML goal: Predict whether a new, unseen email is spam or not.
Data Explosion and Impact

Autonomous Future Predictions Generating


Vehicles Artworks

Intelligent Intelligent Image


Agents Marketing Understanding

Risk Analysis Brain Tumor


Detection Contact
Tracing
Sentiment
Analysis

...
Sports
Analytics
AI Applications
• AI Mimics Human Tasks: AI is designed to perform tasks that usually
require human intelligence, such as recognizing patterns, making
decisions, and solving problems.
• Key Question: "What human task could AI automate or enhance?"
AI for Design Creativity
• Generative AI models excel at blending diverse concepts,
enabling designers to explore novel and unique ideas.
• They can provide creative solutions that may not be immediately
obvious, acting as a valuable inspiration tool.

+ =

mole rat car


Categories of Learning
• Supervised Learning: In this type of learning, we have a clear goal in mind. We use
labeled data to train our model. The model's job is to learn from this data and make
accurate predictions or decisions.
• Classification: Sorting data into categories (e.g., Spam or Not Spam).
• Regression: Predicting numerical values (e.g., House Prices).
• Unsupervised Learning: Here, we give the model data but no explicit instructions on
what to do with it. The model tries to identify patterns or structures in the data.
• Example: Clustering customers based on purchasing behavior.
• The choice between supervised and unsupervised learning depends on what you want to
achieve. Supervised is goal-oriented with known outcomes, while unsupervised is more
about exploring unknown patterns.
Supervised Learning (classification)
• The output of the model is the probability of belonging to a
class
• NOTE: We know the labels (spam/not spam) in our training
data

Spam Classification
Source: Hands-on Machine Learning with Scikit-Learn, Keras, and TensorFlow, Second Edition,
Aurélien Géron
Supervised Learning (regression)
• The output of the model is one (or many) real-valued
number(s)
• NOTE: We know the numerical values of the target variable in
our training data

Source: Hands-on Machine Learning with Scikit-Learn, Keras, and TensorFlow, Second Edition, Aurélien Géron
Unsupervised Learning
• Imagine we have collected data from an e-
commerce website but have not attached any
labels to it. The data includes:
• Customer IDs
• Products viewed
• Time spent on each product page
• Frequency of visits
• Cart additions and removals
• This data is considered unlabeled because it Source: Hands-on Machine Learning with Scikit-

doesn't tell us anything specific about the Learn, Keras, and TensorFlow, Second Edition,
Aurélien Géron

customer's intent or categorization, such as


whether they are a “high-value” customer or a
“window shopper.”
Unsupervised Learning
• We can use unsupervised learning
algorithms like clustering to group similar
customers together based on their
behavior.
• For instance, customers who frequently
view high-priced items and spend a lot of
time on the website might be grouped
into a "Potential High-Value Customer" Source: Hands-on Machine Learning with Scikit-

cluster. Learn, Keras, and TensorFlow, Second Edition,


Aurélien Géron
Unsupervised Learning – Anomaly Detection
• In the context of unsupervised learning,
anomaly detection is about identifying
outliers or unusual patterns in the data.
There are no labels telling us what's
"normal" and what's an "anomaly"; the
model figures this out on its own
• Points that don't fit well into any cluster
are considered anomalies
• This is particularly useful in areas like Source: Hands-on Machine Learning with Scikit-Learn, Keras,
fraud detection, network security, and and TensorFlow, Second Edition, Aurélien Géron

quality control
Self-Supervised Learning
• Focus of the next lecture
• A method to train models to “reconstruct” the training data
• ChatGPT is a good example
• Unlike unsupervised learning, self-supervised learning does not
perform the grouping and clustering of data, but focus on the
generation of data
Self-Supervised Learning
• Usually involves examining part of a data to figure out (guess) the remaining part

“This is a sport car” Tokenize

reconstruct
ML model after
being trained on a
lot of car’s images!
BLOCKED

(ML model has learned:


1. Forward facing car
2. Headlights are symmetric
3. Car’s orientation
4. Car has a windshield
5. etc...
Self-Supervised Learning (text generation)
• Transformers: A type of advanced neural network architecture used
in large language models like ChatGPT.
• How They Work: Transformers predict the next "token" (a word or
part of a word) based on the context of previous tokens in a
sequence, enabling coherent text generation
input tokens output probabilities

cat
sit mat (93%)
on
a
What’s the next word?

tokens!

Probabilities!

https://poloclub.github.io/transformer-explainer/
Application of AI in
Engineering
GPT Models as a Research Partner
• GPT models assist in brainstorming, generating
creative concepts, simulate your users, and
exploring design variation
Utilizing GPT Models for Customer Insights
• Simulate Customer Personas: Use GPT models
to create diverse customer personas and
gather feedback from various perspectives
• Generate Opinions at Scale: Ask these
simulated personas for their opinions on
products, services, or design decisions to
refine and improve offerings
• Solve Design Challenges: Simulate large
populations to stress-test design solutions and
predict potential user reactions across
demographics

https://arxiv.org/abs/2404.16045
AI for Mechanical Configuration Design
• We will have an invited speaker to discuss AI for configuration design!
AI for Manufacturing – Fault Detection
• Real-time Monitoring: Instant
detection of defects

Faulty sample

https://arxiv.org/pdf/2301.11514
AI for Discovery

You might also like