Extending k8s API and Lesser known neural networks in Go

3a05235ac9d98378afddbaf95c0d1f6f?s=47 Milos Gajdos
November 01, 2017

Extending k8s API and Lesser known neural networks in Go

Slides from the talk I gave at Golang Taipei on 31st October, 2017

3a05235ac9d98378afddbaf95c0d1f6f?s=128

Milos Gajdos

November 01, 2017
Tweet

Transcript

  1. K8S & LESSER KNOWN NEURAL NETWORKS IN GO GOLANG TAIPEI

    GATHERING #29
  2. ABOUT ME ▸ Masters in Cybernetics, CTU, Prague ▸ Started

    Kubernetes London Meetup ▸ Containers: https://containerops.org/ ▸ Machine Learning: https://mlexplore.org/ ▸ Twitter: @milosgajdos ▸ Github: milosgajdos83
  3. TONIGHT KUBERNETES LONDON MEETUP EXTENDING K8S WITH GO NEURAL NETWORKS

    IN GO QUIZ!
  4. LET’S TALK ABOUT KUBERNETES LONDON

  5. KUBERNETES LONDON MEETUP ▸ Started w/ Peter Idah (@peteridah) in

    Feb 2015 ▸ Currently almost 2k members ▸ Growing strong…still
  6. None
  7. LET’S TALK ABOUT KUBERNETES

  8. KUBERNETES IN NUTSHELL ▸ Users interact with k8s [only] via

    API service ▸ Everything [useful] is an API object ▸ Users create them, Control Plane manages them ▸ Control Plane is a “Kernel”, APIs are “standard libs”
  9. KUBERNETES IS THE POSIX OF THE CLOUD James Strachan, Redhat

  10. EXTENDING KUBERNETES [API]

  11. API SERVICE SHIPS AS A COMPILED BINARY

  12. NEW K8S RELEASE SHIPS QUARTERLY

  13. CONTRIBUTING TO K8S IS NOT EASY!

  14. WHAT IF I TOLD YOU…ABOUT CDR?

  15. CUSTOM RESOURCE DEFINITION (CRD) ▸ Extend k8s API with custom

    objects ▸ CDRs allow to use familiar UX: kubectl ▸ On their own just “dumb” storage of structured data ▸ Powerful in combination with CONTROLLERS
  16. CDR EXAMPLE

  17. CRD IN ACTION

  18. CONTROLLERS GIVE YOU CDR SUPERPOWERS…SORT OF

  19. CDR CONTROLLER IN ACTION

  20. CONTROLLER REGISTRATION

  21. CDR CONTROLLERS IN GO ▸ Easy to create, well…sort of

    :-) ▸ Sample controller:
 https://github.com/kubernetes/sample-controller ▸ Dig into the code deeper: 
 https://goo.gl/d12pQK ▸ Go even deeper: API aggregation ▸ Credit: James Munnelly (@JamesMunnelly )
  22. LET’S TALK ABOUT NEURAL NETWORKS

  23. WHY GO AND NEURAL NETWORKS ▸ Go is fun! Well,

    most of the time ;-) ▸ Statically typed language, memory safe ▸ Easy concurrency ▸ Reasonably fast [and still improving] runtime
  24. PYTHON [R] + CUDA LEADING THE WAY

  25. FPGA+GO=OK FOR SOME WORKLOADS

  26. BUT STILL NOWHERE NEAR CUDA GPU MAGIC

  27. YOU NEED A GOOD NUMERICAL LIBRARY

  28. GO FOR NUMERICAL & SCIENTIFIC COMPUTING ▸ gonum: set of

    Go libraries for scientific computing
 https://www.gonum.org ▸ Numerical computations and optimization problems:
 https://github.com/gonum/gonum ▸ Particularly interesting packages:
 mat: matrix operations
 optimize: optimisation problems ▸ Plotting graphs:
 https://github.com/gonum/plot
  29. CREATE MATRIX

  30. BASIC MATRIX OPERATIONS

  31. TRANSFORM MATRIX OPERATIONS

  32. MATRIX VIEW OPERATIONS

  33. STATISTICS, COMPARISONS ETC.

  34. SOME NOTES ▸ The result of Matrix operation stored in

    receiver: ▸ Receiver must be initialized! ▸ Receiver get mutated by the operation! ▸ Panics when the indexes are out of bounds! ▸ Some operations return Vector, not Matrix! ▸ You can access raw backing data (float64 slices)
  35. LESSER KNOWN NEURAL NETS…IN GO

  36. SELF ORGANISING MAPS (SOM) ▸ Data clustering ▸ Unsupervised learning

    ▸ gosom: SOM implementation in Go
 https://github.com/milosgajdos83/gosom ▸ http://mlexplore.org/2017/01/13/ self-organizing-maps-in-go/
  37. HOPFIELD NETWORKS ▸ Associative memory ▸ Supervised learning ▸ gopfield:

    Hopfield networks in Go
 https://github.com/milosgajdos83/gopfield ▸ http://mlexplore.org/2017/03/12/ hopfield-networks-in-go/
  38. TIPS AND TRICKS ▸ Sometimes looping over a raw vector

    slice is faster than multiplying vectors using mat package functions
 AVOID UNNECESSARY ALLOCATIONS ▸ Avoid re-computing CPU “expensive” values (pow, exp…)
 CACHE AND RE-USE EXPENSIVE COMPUTATIONS ▸ Go Profiler is pretty awesome and it’s your best friend
 AVOID PREMATURE OPTIMISATIONS
  39. SUMMARY ▸ Extending k8s API is simple and can give

    you super powers ▸ Neural Networks in Go are fun, but Python + CUDA still faster ▸ Stay awesome and keep hacking in Go!
  40. REFERENCES ▸ Gist from this talk
 https://gist.github.com/milosgajdos83/ de311c901572644481d4b5dd3830d6cc ▸ Awesome

    list of Go for data science resources
 https://github.com/gopherdata/resources ▸ gorgonnia = Go + CUDA
 https://github.com/chewxy/gorgonia ▸ Go + FPGA
 https://github.com/ReconfigureIO