automatic synthesis of statistical and machine learning ... › m › groups ›...

21
Automatic Synthesis of statistical and machine learning Algorithms Johann Schumann SGT, Inc., NASA ARC

Upload: others

Post on 29-May-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

AutomaticSynthesisofstatisticalandmachinelearning

AlgorithmsJohannSchumannSGT,Inc.,NASAARC

Page 2: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

Example:Analysisofterminaltrafficpattern

• Giventrajectorydataforlandingandtakeofffromtheairport• Clusteringoftrajectoriestofindstructureinthedata

Let’suseourfavorite“multivariateclustering”software/tool• Matlab• R• Weka• AutoBayes• …

N

Page 3: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

Example:Analysisofterminaltrafficpattern

Result:Num_classes =5

Uups…expectingonly4classes

N

NeedaspecialPDFtohandleangles

Page 4: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

Declarativeproblemspecificationforthetask• declareconstantsandparameters• theclassfrequencyisaprobability,i.e.addsupto1• cistheclassassignment• thedataareGaussiandistributed• Whatdowewant?

• estimatesoftheparameters• returntheclassassignment

Model cluster1 as ‘simple cluster analysis'.const nat N as ’data points'. where 0 < N.const nat C. where 0 < C. where C << N.double µ(0..C-1), s(0..C-1).

double phi(0..C-1) as 'class frequency'.where 0 = sum(_i := 0 .. C-1, phi(_i))-1.

output double c(0..N-1).c(_) ~ discrete(vector(_i := 0 .. C-1, phi(_i))).

data double x(0..N-1).x(_i) ~ gauss(µ(c(_i)), s(c(_i))).

max pr({x} |{phi, s, µ}) for {phi, s, µ}.

Page 5: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

Correcteddeclarativespecification

• Modificationstohandleangles(changesinred)

model ac_track as 'AC track analysis'.const nat N as ’# tracks'. where 0 < N.const nat C. where 0 < C. where C << N.

double phi(0..C-1) as 'class frequency'.where 0 = sum(_i := 0 .. C-1, phi(_i))-1.

output double c(0..N-1).c(_) ~ discrete(vector(_i := 0 .. C-1, phi(_i))).

data double x(0..N-1).

max pr({x |{phi, }for {phi, }.

double l_x(0..C-1),m_x(0..C-1).

x(_i) ~ vonmises(l_x(c(_i)), m_x(c(_i))).

l_hd, m_hdl_hd, m_hd

ThisistheactualinputoftheAutoBayes tool

Page 6: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

ProgramSynthesis• AutoBayes generatedanentirelydifferentalgorithm• 880linesofC++versus582lines• Highlydocumentedcode• InterfacestoMatlab oroctave

Page 7: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

TheAutoBayes Synthesistool

• Toolfortheautomatedgenerationofcustomizeddataanalysisandmachinelearningalgorithms• Bayesianapproachforproblembreak-downandsolution• Fulldeclarativeinputspecifications• Targetlanguages:C,C++• Schema-basedprogramsynthesis

Page 8: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

Schema-basedsynthesis:Example

• Weneedanalgorithmtomaximizemax -5*x**2 + 3*x + 7 for x.

thewecandothetext-bookstyletechnique:

1.calculatethederivative:df/dx2.setitto0:

0=df/dx3.solvethatequationforx4.thesolutionisthedesiredmaximum

Page 9: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

Schemaforunivariateoptimization

1. buildthederivative:df/dx2. setitto0:0=df/dx3. solvethatequationforxand

generatecodeforthat4. thesolutionisthedesired

maximum

schema(max F for X, C) :-% INPUT (Problem), OUTPUT (Code fragment)

length(X, 1),

% calculate the first derivativesimplify(deriv(F, X), DF),% solve the equationsolve(true, 0 = DF, X, S),C = S

..

Page 10: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

Schemaforunivariateoptimizationschema(max F for X, C) :-

% INPUT (Problem), OUTPUT (Code fragment)% guards

length(X, 1),

% calculate the first derivativesimplify(deriv(F, X), DF),% solve the equationsolve(true, x, 0 = DF, S),% is that really a maximum?

simplify(deriv(DF, X), DDF),solve(true, x, 0 < DDF, _),C = S

Page 11: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

Schemaforunivariateoptimizationschema(max F for X, C) :-

% INPUT (Problem), OUTPUT (Code fragment)% guards

length(X, 1),

% calculate the first derivativesimplify(deriv(F, X), DF),% solve the equationsolve(true, x, 0 = DF, S),% possibly more checks% is that really a maximum?

simplify(deriv(DF, X), DDF),(solve(true, x, 0 > DDF, _)-> true ;writeln(‘Proof obligation not solved’)),

C = S

Page 12: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

Schemaforunivariateoptimizationschema(max F for X, C) :-

% INPUT (Problem), OUTPUT (Code fragment)% guards

length(X, 1),

% calculate the first derivativesimplify(deriv(F, X), DF),% solve the equationsolve(true, x, 0 = DF, S),% possibly more checks% is that really a maximum?

simplify(deriv(DF, X), DDF),(solve(true, x, 0 > DDF, _)-> true ;writeln(‘Proof obligation not solved automatically’)),XP = [‘The maximum for‘, expr(F), ‘is calculated ...’],V = pv_fresh,C = let(assign(V, C, [comment(XP)]), V).

Page 13: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

AutoBayes Applications

• NASAOpenSource:https://software.nasa.gov/software/ARC-16276-1• Manual:https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20080042409.pdf

educational

AstrophysicsSoftwareTesting

AirTrafficControl

EarthScience/Geodata

Page 14: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

AlgorithmDesignviaSynthesis• Anappropriatemachine-learningalgorithm isthebasisforeachapplication• Somedomainsrequirespecializedalgorithmsoralgorithmvariantsforthespecifictaskathand.Examples:• Clustering,Optimization,Filtering

• Someprogramsynthesissystems(likeAutoBayes)cangenerateacustomizedalgorithm fromscratchorschemas• Algorithmvariantscanbegeneratedeasilyforthesametask,e.g.• K-means,EM,kd-trees,…forclustering• Gradientdescend,Nelder-Mead,BGFS,Levenberg-Margquart,…foroptimization• Matrix-inverse,Schmidt,Bierman update,etc.forKalman filter

Page 15: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

AlgorithmInstantiationviaSynthesis• ManyMLtasksrequiresubstantialmathematicalpre-calculations• E.g.,discretizationandlinearizationofthestate-transitionmatrixinaKalmanfilter.

• Suchcalculationsneedtobedonebeforetheresultscanbe“plugged”intotheMLalgorithm• Algorithmsoftencanbeimprovedsuchresults(e.g.,matrixisdiagonal)• Examplesofsuchsystems:• AutoFilter:synthesisofKFandEKFalgorithms• *kf:synthesisofKalman filtersoftware[1]

[1]T.McClure.OntheAutomaticGenerationofrecursiveAttitudeDeterminationAlgorithms,AAS2017

Page 16: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

WorkflowbySynthesis• Manymachine-learningtasksrequireanumberofindividualactivities• Readingandparsingofdata• Datatransformationandpreprocessing• Trainingandtesting• Assessmentofresults• Visualization• …

• Work-flowtoolforML• Reduceamountofcustomcode• Increaseflexibility

• Example:• WekaKnowledge-flow(notsynthesisperse)

Page 17: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

ArchitecturebySynthesis• Modernhardwarearchitecturesenablesthefastandefficientexecutionofmachine-learningalgorithms• GPU,MPIcluster,Epiphany,FPGA,Tensorflow,neuromorphic,…

• VeryhighefforttoimplementaMLalgorithmsforaspecifichardwarearchitecture• Veryeasytogetthingswrong• Programsynthesistoolscangenerateefficientandcustomizedalgorithmsforanumberofdifferenttargetarchitectures• Fromasinglehigh-levelalgorithmdescription

• Example:• SpiralGen (spiralgen.com)

Page 18: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

AlgorithmOptimizationbySynthesis

• Systemrequirementscanconstraintime,power,andhardwarealternatives• Whatisthe“best”algorithmandhardwarearchitectureforthegiventaskunderthegivenrequirements?• Synthesistechniquescanhelptosolvethatproblem:• Fastandeffort-lessgenerationofmultiplealgorithmsandarchitecturesforthesameMLtask• Automatedgenerationoftestdata,evaluationandtestenvironments

Page 19: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

WhatelsecansynthesisdoforML?• Automaticgenerationofalgorithmdesigndocumentationanddetailedmathematicalderivations• Automaticgenerationofmultipleartifactsfordebugging,testing,verificationandvalidation

AlgorithmderivationgeneratedbyAutoBayes (excerpt)

Page 20: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

SynthesisforML:Allproblemssolved?

Page 21: Automatic Synthesis of statistical and machine learning ... › m › groups › machinelearning... · analysis and machine learning algorithms •Bayesian approach for problem break-down

SynthesisforML:Allproblemssolved?SynthesissystemsforMLapplicationshavehugeadvantages,but• Veryhardandcostlytodevelopandmaintain• Steeplearningcurvefortheuser,toolsoftentooresearchy• Difficultintegration,understanding,andmodifyingofgeneratedcode

Future• StronglyincreasedneedforMLalgorithmsonspecializedhard/softwareplatforms(UAS,(Cube)Sat,Rovers,…),• AvailabilityofspecialhardwareforML(Tensorflow,neuromorphic,highlyparallel,lowpower),• Rad-hardbyalgorithm,• Advanced,fastchangingMLtasksduringthemissionmakessynthesisforMachine-Learningalgorithmsandsoftwareanexcitingprospect