Download presentation
Presentation is loading. Please wait.
1
Machine Learning, Sebastiano Galazzo
best practices and vulnerabilities Sebastiano Galazzo Microsoft MVP A.I. Category
3
Sebastiano Galazzo Microsoft MVP
@galazzoseba
4
Best practices
5
The perceptron In machine learning, the perceptron is a binary classifier or a function which can decide whether or not an input, represented by a vector of numbers, belongs to some specific class. π π₯ =Ο ( β¨ w , x β© + b ) w is a vector having weights of real values, while operator β¨ β
, β
β© is the scalar product, b is the 'biasβ, a constant not related to any input value and Ο ( y ) is the output function
6
Main evolutions Easy way, Logistic Regression, Support Vector Machine
Pro: Easy and fast use use Cons: Low accuracy (compared to neural networks) Hard way, Neural Networks Pro: If get convergence you gain a very high accuracy (State of the art) Cons: Very difficult to model, a lot of experience is required
7
Easy way Pseudo equation π₯ββ +π¦βπ½+πβπΏ+..+π§βπ=(0,1) #logisticregression #svm
8
Hard way #neuralnetwork
9
Advanced modelling of Neural Networks
Use case, provide a customer's willingness to vote a political party Age Gender Income City Political party 30 Male 38,000 New York Democrat 39 Female 42,000 Page Republican 24 Other 39,000 San Francisco 51 Prefer not to say 71,000 Seattle
10
Advanced modelling of Neural Networks
Age Gender Income City Political party 30 Male 38,000 New York Democrat 39 Female 42,000 Page Republican 24 Other 39,000 San Francisco 51 Prefer not to say 71,000 Seattle 0,17 18,24 25,35 36,45 46,60 >60 ππππ ππππππ π’ππππ ππ’πππ [π π’ππ’ππππ]..[democrat][Republican] > 20 parameters
11
Advanced modelling of Neural Networks
Age Gender Income City Political party 30 Male 38,000 New York Democrat 39 Female 42,000 Page Republican 24 Other 39,000 San Francisco 51 Prefer not to say 71,000 Seattle Age Gender /= 100 /4 [0,100] 0 = Male, 0.25 = Female, 0.5=Other, 0.75 = Prefer not to Say, 1 = Unk [0.25][<20.000][ ][ ][ ]β¦
12
Advanced modelling of Neural Networks
Age Gender Income City Political party 30 Male 38,000 New York Democrat 39 Female 42,000 Page Republican Method 1-of-(C-1) effects-coding: Standard deviation π= 1 π π=1 π π₯ π βπ 2 π=ππ£πππππ ππ πππ π£πππ’ππ
13
Advanced modelling of Neural Networks
Age Gender Income City Political party 30 Male 38,000 New York Democrat 39 Female 42,000 Page Republican age = ( ) / 4 = 40.0 π= 1 π π=1 π π₯ π βπ 2 π= β β β β =8,12
14
Advanced modelling of Neural Networks
Age Gender Income City Political party 30 Male 38,000 New York Democrat 39 Female 42,000 Page Republican π β² = (πβππππ) π π‘π πππ£ π β² input will be used in place of the original input Having the age average is 40.0, standard deviation is 8.12, and our current value is 30.0: 30.0= (30β40) 8.12 = β1.23
15
Advanced modelling of Neural Networks
One of parameters: Italian cities (About 8000) ππππππ ππππππ π
πππ β¦ πΆππ‘ππππ Binary compression: 2 13 =8192 City Value Milano 0,0,0,0,0,0,0,0,0,0,0,0,0,0 Torino 0,0,0,0,1,1,0,0,0,0,0,1,0,0 Catania 0,1,0,0,1,0,0,0,0,1,0,1,1,0 With 13 nodes we can map 8192 values (Having the same meaning/context)
16
Advanced modelling of Neural Networks
Age Gender Income City Political party 30 Male 38,000 New York Democrat 39 Female 42,000 Page Republican β1, ,4 [0.25][0,3] The model has a mapping ratio of 1:1 between concepts and the number of neurons. Only 5 parameters! Can be managed without neural networks by an IF,THEN sequence in the code
17
Advanced modelling of Neural Networks
Data must be manipulated and made understandable by the machine, not for the humans!
18
Vulnerabilities
19
Vulnerabilities Letβs imagine that we run an auction website like Ebay. On our website, we want to prevent people from selling prohibited itemsβ. Enforcing these kinds of rules are hard if you have millions of users. We could hire hundreds of people to review every auction listing by hand, but that would be expensive.
20
Vulnerabilities Instead, we can use deep learning to automatically check auction photos for prohibited items and flag the ones that violate the rules. This is a typical image classification problem.
21
Vulnerabilities β Image Classification
We repeat this thousands of times with thousands of photos until the model reliably produces the correct results with an acceptable accuracy.
22
Vulnerabilities - Convolutional neural networks
Convolutional neural networks are powerful models that consider the entire image when classifying it. They can recognize complex shapes and patterns no matter where they appear in the image. In many image recognition tasks, they can equal or even beat human performance.
23
Vulnerabilities - Convolutional neural networks
With a fancy model like that, changing a few pixels in the image to be darker or lighter shouldnβt have a big effect on the final prediction, right? Sure, it might change the final likelihood slightly, but it shouldnβt flip an image from βprohibitedβ to βallowedβ. βexpectationsβ
24
Vulnerabilities - Convolutional neural networks
It was discovered that this isnβt always true
25
Vulnerabilities - Convolutional neural networks
If you know exactly which pixels to change and exactly how much to change them, you can intentionally force the neural network to predict the wrong output for a given picture without changing the appearance of the picture very much. That means we can intentionally craft a picture that is clearly a prohibited item but which completely fools our neural network
26
Vulnerabilities - Convolutional neural networks
Why is this?
27
Vulnerabilities - Convolutional neural networks
A machine learning classifier works by finding a dividing line between the things itβs trying to tell apart. Hereβs how that looks on a graph for a simple two-dimensional classifier thatβs learned to separate green points (acceptable) from red points (prohibited) Right now, the classifier works with 100% accuracy. Itβs found a line that perfectly separates all the green points from the red points.
28
Vulnerabilities - Convolutional neural networks
But what if we want to trick it into mis-classifying one of the red points as a green point? Whatβs the minimum amount we could move a red point to push it into green territory? If we add a small amount to the Y value of a red point right beside the boundary, we can just barely push it over into green territory. Hereβs how that looks on a graph for a simple two-dimensional classifier thatβs learned to separate green points (acceptable) from red points (prohibited)
29
Vulnerabilities - Convolutional neural networks
In image classification with deep neural networks, each βpointβ we are classifying is an entire image made up of thousands of pixels. That gives us thousands of possible values that we can tweak to push the point over the decision line. If we make sure that we tweak the pixels in the image in a way that isnβt too obvious to a human, we can fool the classifier without making the image look manipulated. Hereβs how that looks on a graph for a simple two-dimensional classifier thatβs learned to separate green points (acceptable) from red points (prohibited) Global AI Nights - London 2019
30
Vulnerabilities - Convolutional neural networks
+ = People Squirel Hereβs how that looks on a graph for a simple two-dimensional classifier thatβs learned to separate green points (acceptable) from red points (prohibited)
31
Perturbation of math model
32
Perturbation of math model
33
Perturbation of math model
34
Perturbation of math model
35
Perturbation of math model
36
Perturbation of math model
37
Perturbation of math model
38
Perturbation of math model
39
Vulnerabilities β The steps
Feed in the photo that we want to hack. Check the neural networkβs prediction and see how far off the image is from the answer we want to get for this photo. Tweak our photo using back-propagation to make the final prediction slightly closer to the answer we want to get. Repeat steps 1β3 a few thousand times with the same photo until the network gives us the answer we want. Hereβs how that looks on a graph for a simple two-dimensional classifier thatβs learned to separate green points (acceptable) from red points (prohibited)
40
Snippet of a Python script using Keras
Vulnerabilities Snippet of a Python script using Keras
41
How can we protect ourselves against these attacks?
Simply create lots of hacked images and include them in your training data set going forward, that seems to make your neural network more resistant to these attacks. This is called Adversarial Training and is probably the most reasonable defense to consider adopting right now. Hereβs how that looks on a graph for a simple two-dimensional classifier thatβs learned to separate green points (acceptable) from red points (prohibited)
42
How can we protect ourselves against these attacks?
Pretty much every other idea researchers have tried so far has failed to be helpful in preventing these attacks. Hereβs how that looks on a graph for a simple two-dimensional classifier thatβs learned to separate green points (acceptable) from red points (prohibited)
44
Thanks! Sebastiano Galazzo Microsoft MVP @galazzoseba
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.