introduction to algorithmic di erentiation

14
Introduction to Algorithmic Differentiation aka: Computational Differentiation Uwe Naumann Informatik 12: Software and Tools for Computational Engineering (STCE) RWTH Aachen

Upload: others

Post on 26-Apr-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Algorithmic Di erentiation

Introduction to Algorithmic Differentiation

aka: Computational Differentiation

Uwe Naumann

Informatik 12:Software and Tools for Computational Engineering (STCE)

RWTH Aachen

Page 2: Introduction to Algorithmic Di erentiation

Contents

Legal

Warm-Up

Motivation

Contents

Admin

,

Introduction to AD, [email protected] 2

Page 3: Introduction to Algorithmic Di erentiation

Outline

Legal

Warm-Up

Motivation

Contents

Admin

,

Introduction to AD, [email protected] 3

Page 4: Introduction to Algorithmic Di erentiation

LegalRecording Live Zoom Sessions

See RWTHmoodle for document outlining the legal side of recording Zoomsessions.

I no issues if video and audio disabled

I if video and/or audio enabled, then you agree to the terms and conditions

Q&A sessions will (probably) not be recorded.

,

Introduction to AD, [email protected] 4

Page 5: Introduction to Algorithmic Di erentiation

Outline

Legal

Warm-Up

Motivation

Contents

Admin

,

Introduction to AD, [email protected] 5

Page 6: Introduction to Algorithmic Di erentiation

Warm-UpWho knows how to differentiate ...

1 y=sin(x)

1 y=exp(sin(x))

1 y=x∗p

1 y∗=x

1 float f(float x) {2 return cos(x);3 }

1 double f(float x) {2 return 42.;3 }

???

,

Introduction to AD, [email protected] 6

Page 7: Introduction to Algorithmic Di erentiation

Warm-UpWho knows how to differentiate ...

1 ...2

3 template<typename T, typename PT>4 void paths(size t ncs, size t from, size t to, T& x, const std::vector<T>& p, const std::

vector<std::vector<PT>>& dW, T& s) {5 using namespace std;6 size t n=p.size()−2;7 T x0=x;8 for (size t j=from;j<to;j++) {9 for (size t i=0;i<n;i+=ncs) steps(j,i,i+ncs,x,p,dW);

10 T sig=1/(1+exp(−(x−p[n])/p[n+1])); s+=(x−p[n])∗sig; x=x0;11 }12 }13 ...

??? ... YOU WILL!

This course introduces Algorithmic Differentiation (AD) as the method ofchoice for computing first and higher derivatives of numerical simulationprograms.

,

Introduction to AD, [email protected] 7

Page 8: Introduction to Algorithmic Di erentiation

Outline

Legal

Warm-Up

Motivation

Contents

Admin

,

Introduction to AD, [email protected] 8

Page 9: Introduction to Algorithmic Di erentiation

MotivationNeed for Cheap Gradients ...

... as well as aerospace, machine learning, finance, ...

,

Introduction to AD, [email protected] 9

Page 10: Introduction to Algorithmic Di erentiation

Outline

Legal

Warm-Up

Motivation

Contents

Admin

,

Introduction to AD, [email protected] 10

Page 11: Introduction to Algorithmic Di erentiation

ContentsOverview

I AD by overloadingI mathsI sample codeI dco/c++

I AD by handI manual generation of derivative code

I AD by compilerI lexical analysis with flexI syntax analysis with bisonI syntax-directed generation of derivative code

,

Introduction to AD, [email protected] 11

Page 12: Introduction to Algorithmic Di erentiation

Outline

Legal

Warm-Up

Motivation

Contents

Admin

,

Introduction to AD, [email protected] 12

Page 13: Introduction to Algorithmic Di erentiation

AdminWhat, When, Where, Who, How?

I Lecture (videos, slides, code @ RWTHmoodle)

I Q&A (U. Naumann on Tuesdays at 10:30am live @ Zoom; invites @RWTHmoodle)

I Tutorial (M. Towara on Thursdays at 12:30am live @ Zoom; invites @RWTHmoodle)I VirtualBox Linux image for tutorial exercises contains dco/c++ and other

software required

I Exams (90min written exams in Feb/Mar/Apr t.b.a.)

I SiSc Lab → separate set of slides following this presentation

,

Introduction to AD, [email protected] 13

Page 14: Introduction to Algorithmic Di erentiation

Questions?

,

Introduction to AD, [email protected] 14