Sensors Approximate computing approximate edge detection Machine - - PowerPoint PPT Presentation

sensors approximate computing
SMART_READER_LITE
LIVE PREVIEW

Sensors Approximate computing approximate edge detection Machine - - PowerPoint PPT Presentation

Uncertain< T > A First-Order Type for Uncertain Data James Bornholt Australian National University Todd Mytkowicz Microsoft Research Kathryn S. McKinley Microsoft Research Sensors Approximate computing


slide-1
SLIDE 1

Uncertain<T>

A First-Order Type for Uncertain Data

James Bornholt Todd Mytkowicz Kathryn S. McKinley

Australian National University Microsoft Research Microsoft Research

slide-2
SLIDE 2

Sensors

slide-3
SLIDE 3

approximate edge detection

Approximate computing

slide-4
SLIDE 4

x0 x1 xD z0 z1 zM y1 yK w(1)

MD

w(2)

KM

w(2)

10

hidden units inputs

  • utputs

Machine learning

slide-5
SLIDE 5
slide-6
SLIDE 6

10 20 30 40 50 60

Time Speed (mph)

slide-7
SLIDE 7

24 mph

10 20 30 40 50 60

Time Speed (mph)

slide-8
SLIDE 8

24 mph

10 20 30 40 50 60

Time Speed (mph)

slide-9
SLIDE 9

Edge detection

slide-10
SLIDE 10

Edge detection

slide-11
SLIDE 11

Edge detection

slide-12
SLIDE 12

Sobel(p)

Edge detection

slide-13
SLIDE 13

Sobel(p) 0.4940

Edge detection

slide-14
SLIDE 14

Sobel(p) 0.4940

Edge detection

slide-15
SLIDE 15

Sobel(p) 0.4940

Edge detection

slide-16
SLIDE 16

0.4940 3.4% average error

Approximate edge detection

slide-17
SLIDE 17

What is the gradient at pixel p? Sobel(p) 3.4% average training error Approximate edge detection

slide-18
SLIDE 18

What is the gradient at pixel p? Sobel(p) 3.4% average training error Is there an edge at pixel p? if ¡(Sobel(p) ¡> ¡0.1) ¡ ¡ ¡ ¡ ¡EdgeFound(); Approximate edge detection

slide-19
SLIDE 19

What is the gradient at pixel p? Sobel(p) 3.4% average training error Is there an edge at pixel p? if ¡(Sobel(p) ¡> ¡0.1) ¡ ¡ ¡ ¡ ¡EdgeFound(); 36% false positives

  • n the same data!

Approximate edge detection

slide-20
SLIDE 20

What is the gradient at pixel p? Sobel(p) 3.4% average training error Is there an edge at pixel p? if ¡(Sobel(p) ¡> ¡0.1) ¡ ¡ ¡ ¡ ¡EdgeFound(); 36% false positives

  • n the same data!

Approximate edge detection

Computation compounds uncertainty!

slide-21
SLIDE 21

¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GeoCoordinate ¡ ¡Location; ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡double ¡ ¡Grad ¡= ¡Sobel(p);

slide-22
SLIDE 22

Uncertain<GeoCoordinate> ¡Location; Uncertain<double> ¡Grad ¡= ¡Sobel(p);

slide-23
SLIDE 23

Uncertain<T> is an uncertain type abstraction.

  • It encourages non-expert developers to explicitly

reason about uncertainty.

slide-24
SLIDE 24
slide-25
SLIDE 25

Uncertain<GeoCoordinate> ¡LastLoc ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPS.GetLocation(); ¡ Sleep(5); ¡ Uncertain<GeoCoordinate> ¡Loc ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPS.GetLocation(); ¡

slide-26
SLIDE 26

Uncertain<GeoCoordinate> ¡LastLoc ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPS.GetLocation(); ¡ Sleep(5); ¡ Uncertain<GeoCoordinate> ¡Loc ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPS.GetLocation(); ¡ Uncertain<double> ¡Dist ¡= ¡ ¡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¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡ print("Your ¡speed: ¡" ¡+ ¡Speed.E());

slide-29
SLIDE 29

Uncertain<GeoCoordinate> ¡LastLoc ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPS.GetLocation(); ¡ Sleep(5); ¡ Uncertain<GeoCoordinate> ¡Loc ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPS.GetLocation(); ¡ Uncertain<double> ¡Dist ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPS.Distance(Loc, ¡LastLoc); ¡ Uncertain<double> ¡Speed ¡= ¡Dist ¡/ ¡5; ¡ if ¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡ print("Your ¡speed: ¡" ¡+ ¡Speed.E());

Just $24.99

slide-30
SLIDE 30

BUGS, Church, Infer.NET, …

Probabilistic programming

slide-31
SLIDE 31

BUGS, Church, Infer.NET, …

x0 x1 xD z0 z1 zM y1 yK w(1)

MD

w(2)

KM

w(2)

10

hidden units inputs

  • utputs

Probabilistic programming

slide-32
SLIDE 32

BUGS, Church, Infer.NET, …

x0 x1 xD z0 z1 zM y1 yK w(1)

MD

w(2)

KM

w(2)

10

hidden units inputs

  • utputs

Probabilistic programming

slide-33
SLIDE 33

BUGS, Church, Infer.NET, …

x0 x1 xD z0 z1 zM y1 yK w(1)

MD

w(2)

KM

w(2)

10

hidden units inputs

  • utputs

Probabilistic programming

Uncertain<T> helps developers without statistics PhDs.

slide-34
SLIDE 34

Uncertain<GeoCoordinate> ¡LastLoc ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPS.GetLocation(); A variable of type Uncertain<T> is a random variable, represented by a distribution.

slide-35
SLIDE 35

Uncertain<GeoCoordinate> ¡LastLoc ¡= ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡GPS.GetLocation(); A variable of type Uncertain<T> is a random variable, represented by a distribution.

“We define accuracy as the radius of 68% confidence [of a] normal distribution.” —Android

slide-36
SLIDE 36

Sampling functions return random samples.

slide-37
SLIDE 37

Sampling functions return random samples. Simple computations. ✓

slide-38
SLIDE 38

Sampling functions return random samples. Simple computations. Represent many distributions. ✓ ✓

slide-39
SLIDE 39

Sampling functions return random samples. Simple computations. Represent many distributions. Sampling is approximate. (Later: how Uncertain<T> learned to love approximation, and you can too) ✓ ✓ ✗

slide-40
SLIDE 40

Uncertain<double> ¡Speed ¡= ¡Dist ¡/ ¡5; ¡

slide-41
SLIDE 41

Uncertain<double> ¡Speed ¡= ¡Dist ¡/ ¡5; ¡ Or more generally, Z ¡= ¡X ¡+ ¡Y, if X and Y are distributions.

slide-42
SLIDE 42

Uncertain<double> ¡Speed ¡= ¡Dist ¡/ ¡5; ¡ Or more generally, Z ¡= ¡X ¡+ ¡Y, if X and Y are distributions.

X Y

slide-43
SLIDE 43

Uncertain<double> ¡Speed ¡= ¡Dist ¡/ ¡5; ¡ Or more generally, Z ¡= ¡X ¡+ ¡Y, if X and Y are distributions.

X Y Z=X+Y

slide-44
SLIDE 44

Uncertain<double> ¡Speed ¡= ¡Dist ¡/ ¡5; ¡ Or more generally, Z ¡= ¡X ¡+ ¡Y, if X and Y are distributions.

X Y Z=X+Y

is a sample of X is a sample of Y is a sample of X+Y * If and then x y x+y

* if X and Y are independent

slide-45
SLIDE 45
slide-46
SLIDE 46

D ¡= ¡A ¡/ ¡B E ¡= ¡D ¡– ¡C ¡ Bayesian network representation:

  • C

/ E B A D

slide-47
SLIDE 47

D ¡= ¡A ¡/ ¡B E ¡= ¡D ¡– ¡C ¡ Bayesian network representation:

  • C

/ E B A D

Sampling function for E recursively samples children.

slide-48
SLIDE 48

is a sample of X is a sample of Y is a sample of X+Y * If and then x y x+y * Only if X and Y are independent.

slide-49
SLIDE 49

is a sample of X is a sample of Y is a sample of X+Y * If and then x y x+y * Only if X and Y are independent. A ¡= ¡X ¡+ ¡Y ¡ B ¡= ¡A ¡+ ¡X ¡ (X,Y independent)

slide-50
SLIDE 50

is a sample of X is a sample of Y is a sample of X+Y * If and then x y x+y * Only if X and Y are independent. A ¡= ¡X ¡+ ¡Y ¡ B ¡= ¡A ¡+ ¡X ¡ (X,Y independent) A and B depend on X – not independent!

slide-51
SLIDE 51

is a sample of X is a sample of Y is a sample of X+Y * If and then x y x+y * Only if X and Y are independent. A ¡= ¡X ¡+ ¡Y ¡ B ¡= ¡A ¡+ ¡X ¡ (X,Y independent) A and B depend on X – not independent!

+ X + B X Y A

slide-52
SLIDE 52

is a sample of X is a sample of Y is a sample of X+Y * If and then x y x+y * Only if X and Y are independent. A ¡= ¡X ¡+ ¡Y ¡ B ¡= ¡A ¡+ ¡X ¡ (X,Y independent) A and B depend on X – not independent!

+ X + B X Y A + + B X Y A

slide-53
SLIDE 53

if ¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡

slide-54
SLIDE 54

if ¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡

2 4 6 8 10

Speed (mph)

slide-55
SLIDE 55

if ¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡

2 4 6 8 10

Speed (mph)

slide-56
SLIDE 56

if ¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡

2 4 6 8 10

Speed (mph)

slide-57
SLIDE 57

if ¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡

4 mph

2 4 6 8 10

Speed (mph)

slide-58
SLIDE 58

if ¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡

4 mph

2 4 6 8 10

Speed (mph)

slide-59
SLIDE 59

if ¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡

4 mph

2 4 6 8 10

Speed (mph) Pr[Speed > 4]

slide-60
SLIDE 60

if ¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡

4 mph

2 4 6 8 10

Speed (mph) Pr[Speed > 4]

More likely than not that Speed > 4?

> 0.5?

slide-61
SLIDE 61

if ¡(Speed ¡> ¡4) ¡print("Great ¡job!"); ¡

4 mph

2 4 6 8 10

Speed (mph) Pr[Speed > 4]

More likely than not that Speed > 4?

> 0.5?

slide-62
SLIDE 62

if ¡(Speed ¡> ¡4).Pr(0.9) ¡print("Great ¡job!"); ¡

4 mph

2 4 6 8 10

Speed (mph) Pr[Speed > 4] > 0.9?

slide-63
SLIDE 63

if ¡(Speed ¡> ¡4).Pr(0.9) ¡print("Great ¡job!"); ¡

4 mph

2 4 6 8 10

Speed (mph) Pr[Speed > 4]

At least 90% likely that Speed > 4?

> 0.9?

slide-64
SLIDE 64

Pr[Speed > 4] > 0.9 if ¡(Speed ¡> ¡4).Pr(0.9) ¡print("Great ¡job!"); ¡

slide-65
SLIDE 65

Pr[Speed > 4] > 0.9 approximate! if ¡(Speed ¡> ¡4).Pr(0.9) ¡print("Great ¡job!"); ¡

slide-66
SLIDE 66

Pr[Speed > 4] > 0.9 approximate! if ¡(Speed ¡> ¡4).Pr(0.9) ¡print("Great ¡job!"); ¡

slide-67
SLIDE 67

Pr[Speed > 4] > 0.9 approximate! Pr[Speed > 4] ≤ 0.9 H0:

null hypothesis

if ¡(Speed ¡> ¡4).Pr(0.9) ¡print("Great ¡job!"); ¡

slide-68
SLIDE 68

Pr[Speed > 4] > 0.9 approximate! HA: Pr[Speed > 4] ≤ 0.9 H0:

null hypothesis alternate hypothesis

if ¡(Speed ¡> ¡4).Pr(0.9) ¡print("Great ¡job!"); ¡

slide-69
SLIDE 69

Pr[Speed > 4] > 0.9 approximate! HA: Pr[Speed > 4] ≤ 0.9 H0:

null hypothesis alternate hypothesis

How many samples? if ¡(Speed ¡> ¡4).Pr(0.9) ¡print("Great ¡job!"); ¡

slide-70
SLIDE 70

Pr[Speed > 4] > 0.9 approximate! HA: Pr[Speed > 4] ≤ 0.9 H0:

null hypothesis alternate hypothesis

How many samples? Too many = too slow Too few = too noisy if ¡(Speed ¡> ¡4).Pr(0.9) ¡print("Great ¡job!"); ¡

slide-71
SLIDE 71

Pr[Speed > 4] > 0.9 approximate! HA: Pr[Speed > 4] ≤ 0.9 H0:

null hypothesis alternate hypothesis

How many samples? Too many = too slow Too few = too noisy Sequential sampling: sample size depends on progress if ¡(Speed ¡> ¡4).Pr(0.9) ¡print("Great ¡job!"); ¡

slide-72
SLIDE 72

0.00 0.05 0.10 0.15 0.20 0.25

Location Density

Likelihood

slide-73
SLIDE 73

0.00 0.05 0.10 0.15 0.20 0.25

Location Density

Likelihood

Incorporate domain knowledge: “I’m on a road”

slide-74
SLIDE 74

0.00 0.05 0.10 0.15 0.20 0.25

Location Density

Prior Likelihood

Incorporate domain knowledge: “I’m on a road”

slide-75
SLIDE 75

0.00 0.05 0.10 0.15 0.20 0.25

Location Density

Prior Likelihood

Incorporate domain knowledge: “I’m on a road”

Pr[H|E] = Pr[E|H] Pr[H] Pr[E]

posterior likelihood prior

slide-76
SLIDE 76

Pr[H|E] = Pr[E|H] Pr[H] Pr[E]

posterior likelihood prior

0.00 0.05 0.10 0.15 0.20 0.25

Location Density

Prior Likelihood Posterior

Incorporate domain knowledge: “I’m on a road”

slide-77
SLIDE 77

Case studies

Smartphone GPS sensors Noisy Game of Life (see the paper) Neural networks/approximate computing

slide-78
SLIDE 78

10 20 30 40 50 60

Time Speed (mph)

GPS speed

slide-79
SLIDE 79

10 20 30 40 50 60

Time Speed (mph)

GPS speed (95% CI)

slide-80
SLIDE 80

10 20 30 40 50 60

Time Speed (mph)

GPS speed (95% CI) Improved speed (95% CI)

slide-81
SLIDE 81

What is the gradient at pixel p? Sobel(p) 3.4% average error Is there an edge at pixel p? Sobel(p) ¡> ¡0.1 36% false positives!

slide-82
SLIDE 82

single input

slide-83
SLIDE 83

single input

slide-84
SLIDE 84

single

  • utput

single input

slide-85
SLIDE 85

single

  • utput

single input approximate

slide-86
SLIDE 86

Single output 0.1

0.00 0.05 0.10 0.15 0.20 0.25

Value of Sobel operator

Is there an edge at pixel p? Sobel(p) ¡> ¡0.1 36% false positives!

slide-87
SLIDE 87

True value Single output 0.1

0.00 0.05 0.10 0.15 0.20 0.25

Value of Sobel operator

Is there an edge at pixel p? Sobel(p) ¡> ¡0.1 36% false positives!

slide-88
SLIDE 88

True value Single output 0.1

0.00 0.05 0.10 0.15 0.20 0.25

Value of Sobel operator

Is there an edge at pixel p? Sobel(p) ¡> ¡0.1 36% false positives!

slide-89
SLIDE 89

True value Single output 0.1

0.00 0.05 0.10 0.15 0.20 0.25

Value of Sobel operator

Is there an edge at pixel p? Sobel(p) ¡> ¡0.1 36% false positives!

slide-90
SLIDE 90

True value Single output 0.1

0.00 0.05 0.10 0.15 0.20 0.25

Value of Sobel operator

Is there an edge at pixel p? Sobel(p) ¡> ¡0.1 36% false positives!

Pr[Sobel(p) > 0.1] = 70%

slide-91
SLIDE 91

60% 80% 100% 0.5 0.6 0.7 0.8 0.9

Conditional threshold Precision/Recall (%) Pr[Sobel(p) > 0.1] > α α

slide-92
SLIDE 92

Naive Precision Naive Recall

60% 80% 100% 0.5 0.6 0.7 0.8 0.9

Conditional threshold Precision/Recall (%) Pr[Sobel(p) > 0.1] > α α

slide-93
SLIDE 93

Naive Precision Naive Recall

60% 80% 100% 0.5 0.6 0.7 0.8 0.9

Conditional threshold Precision/Recall (%) Pr[Sobel(p) > 0.1] > α α Higher precision = fewer false positives

slide-94
SLIDE 94

Naive Precision Naive Recall

60% 80% 100% 0.5 0.6 0.7 0.8 0.9

Conditional threshold Precision/Recall (%) Pr[Sobel(p) > 0.1] > α α Higher precision = fewer false positives Higher recall = fewer false negatives

slide-95
SLIDE 95

Naive Precision Naive Recall

60% 80% 100% 0.5 0.6 0.7 0.8 0.9

Conditional threshold Precision/Recall (%)

Uncertain<T> Precision Recall

Pr[Sobel(p) > 0.1] > α α Higher precision = fewer false positives Higher recall = fewer false negatives

slide-96
SLIDE 96

Uncertain<T> is an uncertain type abstraction.

  • It encourages non-expert developers to explicitly

reason about uncertainty.

slide-97
SLIDE 97

Uncertain<T> is an uncertain type abstraction.

  • It encourages non-expert developers to explicitly

reason about uncertainty. Thank you!