SlideShare a Scribd company logo
Machine Learning
with TensorFlow
Max Kleiner 10.2018
2
TensorFlow Agenda
2https://www.esecurityplanet.com/views/article.php/1501001/Security-Threat-Correlation-The-Next-Battlefield.htm
 3 Cases
– XOR, MNIST, Image Cluster with QT 5
Sacred Experiment Log Recorder
Most experiments score with metrics as confusion matrix
 What's behind TF ? (pattern recognition)
 Cluster & Classify with different inputs, params, config
Define label or topic ratings, hyper-parameters,
– assumed/implicit labels, predict versus target
 Conclusions/ ML Data-mining Summary/
CASSANDRASystem
3
What is TensorFlow?
Intro Link to EuroPython
 Probabilistic (NB, MNB, PD,
BN, BC, PLSA, LDA, ...)
 Independence assumptions
made
 Stochastic or Distance-based
(SVM, matching, VSIM, k-
NN,CR, PageRank,Kmeans)
 Features used
 Structures exploited
 Model-based (rules, BC, BN,
boosting)
 Social media driven
4
4
https://www.springboard.com/blog/data-mining-python-tutorial/
Baseline Perceptron (MLP) with XOR
C:maXboxBASTA2018xor_perceptron.py
http://playground.tensorflow.org_maXbox1
http://playground.tensorflow.org_maXbox2
5
5
https://www.springboard.com/blog/data-mining-python-tutorial/
MNIST Classify Task
https://datascienceplus.com/mnist-for-machine-learning-beginners-with-softmax-regression/
6
MNIST Confusion Matrix
6
CASSANDRASystem
7
from keras.datasets import mnist
0 1 2 3 4
5 6 7 8 9
 76 english, 38 content="voa,
 36 美国之音 " 74 special hand written
 44 Modified National Institute of Standards and
Technology database)
 36 голос 36 америки
The MNIST dataset is comprised of 70,000 handwritten numeric
digit images and their respective labels 0..9.
2. Main: C:maXboxmX46210DataScienceplot_confusion_matrix_vectormachine.py
3. Second C:maXboxmX46210DataScienceconfusionlistmnist_softmax21.py
https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/4_Utils/tensorboard_basic.ipynb
There are 60,000 training images and 10,000 test images, all of
which are 28 pixels by 28 pixels.
CASSANDRASystem
8
QT from keras import backend as K
@ex.automain
def define_and_train(batch_size, epochs,
convolution_layers, maxpooling_pool_size, maxpooling_dropout,
dense_layers, dense_dropout, final_dropout,_run):
from keras.models import Sequential #convolution
from keras.layers import Dense, Dropout, Flatten, Conv2D,
from keras.utils import to_categorical
from keras.losses import categorical_crossentropy
from keras.optimizers import Adadelta
from keras import backend as K
from keras.callbacks import ModelCheckpoint, Callback
4. C:maXboxmX46210ntwdblib.dllUnsharpDetector-masterUnsharpDetector-masterinference_gui.py
CASSANDRASystem
9
MongoDB/Sacred module import class
0 1 2 3 4
5 6 7 8 9
from __future__ import division, print_function,
unicode_literals
from sacred import Experiment
from sacred.observers import MongoObserver
from sacred.utils import apply_backspaces_and_linefeeds
import pymongo, pickle, os
import pydot as pdot
import numpy as np
import tensorflow as tf
5. C:maXboxmX46210DataScienceconfusionlisttrain_convnet_tf.py
CASSANDRASystem
10
MongoDB
 Start the shell process mongod from
 Call from script or start mongod: C:Program
FilesMongoDBServer3.6bin>mongod
CASSANDRASystem
11
MongoDB My Cluster sacred.runs & completed
12
12
MNIST Sacred Training & Test
13
13
Task Manager
14
14
Task II
15
15
Task III
https://pythonexample.com/search/mnist%20tensorboard%20demo/8
16
16
What's behind test ? (backend pattern, crossentropy)
60000/60000 [==============================] - 426s 7ms/step - loss: 0.4982 - acc: 0.8510 -
val_loss: 0.0788 - val_acc: 0.9749
Using TensorFlow backend.
INFO - MNIST-Convnet4 - Result: 0.9749
INFO - MNIST-Convnet4 - Completed after 0:07:27
Test loss: 0.0788029053777
Test accuracy: 0.9749
 59392/60000 [============================>.] - ETA: 5s - loss: 0.0571 - acc: 0.9829
 59520/60000 [============================>.] - ETA: 3s - loss: 0.0572 - acc: 0.9829
 59648/60000 [============================>.] - ETA: 2s - loss: 0.0572 - acc: 0.9829
 59776/60000 [============================>.] - ETA: 1s - loss: 0.0572 - acc: 0.9829
 59904/60000 [============================>.] - ETA: 0s - loss: 0.0573 - acc: 0.9829
 60000/60000 [==============================] - 513s 9ms/step - loss: 0.0573 - acc:
0.9829 - val_loss: 0.0312 - val_acc: 0.9891
 Using TensorFlow backend.
 INFO - MNIST-Convnet4 - Result: 0.9891
 INFO - MNIST-Convnet4 - Completed after 0:33:28
 Test loss: 0.0311644290059
 Test accuracy: 0.9891

17
17
What's behind code ? (keras, pymongo, pydot, graphviz)
db = pymongo.MongoClient('mongodb://localhost:27017/').sacred
print(tf.__version__)
os.environ["PATH"] += os.pathsep +
'C:/Program Files (x86)/Graphviz2.38/bin/'
from tensorflow.examples.tutorials.mnist import input_data
ex = Experiment("MNIST-Convnet4")
ex.observers.append(MongoObserver.create())
ex.captured_out_filter = apply_backspaces_and_linefeeds
https://www.programcreek.com/python/example/103267/keras.datasets.mnist.load_data
18
18https://github.com/pinae/Sacred-MNIST/blob/master/train_convnet.py
Whats behind 64-bit Python: PIP3 Install
pip3 install sacred
Collecting sacred
Downloading
https://files.pythonhosted.org/packages/2d/86/7be3af
a4d4c1c0c76a5de03e5ff779797ab2654e377685255c11c13c0e
a5/sacred-0.7.3-py2.py3-none-any.whl (82kB)
Collecting pymongo
Downloading
https://files.pythonhosted.org/packages/46/39/b9bb7fed3e3a0ea621a1
512a938c105cd996320d7d9894d8239ca9093340/pymongo-3.6.1-cp36-cp36m-
win_amd64.whl (291kB)
100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 296kB 728kB/s
Installing collected packages: pymongo
Successfully installed pymongo-3.6.1
19
19
Machine Learning Jokes ;-)
1. There are two kinds of data scientists:
1) Those who can extrapolate from
incomplete data.
2. In data science, 80 percent of time
spent is preparing data, 20 percent of
time is spent complaining about the need
to prepare data.
https://maxbox4.wordpress.com/
http://www.softwareschule.ch/examples/machinelearning.jpg
CASSANDRASystem
20
https://www.kaggle.com/
similarity of doc a to doc b =
''
)',(
),(
)',(
),(
),(
word
'
2
'
2
BA
jbv
jbv
jav
jav
basim
i
jj

 

21
SUMMARY & QUESTIONS
21
https://maxbox4.wordpress.com/

More Related Content

PDF
EKON22 Introduction to Machinelearning
PDF
Building ML Pipelines
PPT
Dbms plan - A swiss army knife for performance engineers
PDF
K-Fashion 경진대회 3등 수상자 솔루션
PDF
Riyaj: why optimizer_hates_my_sql_2010
PDF
Px execution in rac
PDF
TensorFlow BASTA2018 Machinelearning
PPTX
Performance and how to measure it - ProgSCon London 2016
EKON22 Introduction to Machinelearning
Building ML Pipelines
Dbms plan - A swiss army knife for performance engineers
K-Fashion 경진대회 3등 수상자 솔루션
Riyaj: why optimizer_hates_my_sql_2010
Px execution in rac
TensorFlow BASTA2018 Machinelearning
Performance and how to measure it - ProgSCon London 2016

Similar to Ekon22 tensorflow machinelearning2 (20)

PDF
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
PDF
Scale Container Operations with AIOps
PDF
Training ImageNet-1k ResNet50 in 15min pfn
PPTX
Team_8_CSM_B_Presentatbbvvvvvvion[1].pptx
PPTX
Learning Predictive Modeling with TSA and Kaggle
PDF
Data day2017
PDF
Jacopo Nardiello - Monitoring Cloud-Native applications with Prometheus - Cod...
PDF
Query Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
PPTX
Performance is a Feature!
PDF
Nyc open-data-2015-andvanced-sklearn-expanded
PDF
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
PDF
Software Frameworks for Deep Learning (D1L7 2017 UPC Deep Learning for Comput...
PPTX
Performance is a feature! - London .NET User Group
PDF
Towards a Unified Data Analytics Optimizer with Yanlei Diao
PDF
Summarizing Software API Usage Examples Using Clustering Techniques
PDF
Java In-Process Caching - Performance, Progress and Pitfalls
PDF
Java In-Process Caching - Performance, Progress and Pittfalls
ODP
Caching and tuning fun for high scalability
PDF
maxbox starter60 machine learning
PPTX
Performance is a Feature! at DDD 11
Deep Learning for Computer Vision: Software Frameworks (UPC 2016)
Scale Container Operations with AIOps
Training ImageNet-1k ResNet50 in 15min pfn
Team_8_CSM_B_Presentatbbvvvvvvion[1].pptx
Learning Predictive Modeling with TSA and Kaggle
Data day2017
Jacopo Nardiello - Monitoring Cloud-Native applications with Prometheus - Cod...
Query Optimization with MySQL 8.0 and MariaDB 10.3: The Basics
Performance is a Feature!
Nyc open-data-2015-andvanced-sklearn-expanded
A Tale of Three Deep Learning Frameworks: TensorFlow, Keras, & PyTorch with B...
Software Frameworks for Deep Learning (D1L7 2017 UPC Deep Learning for Comput...
Performance is a feature! - London .NET User Group
Towards a Unified Data Analytics Optimizer with Yanlei Diao
Summarizing Software API Usage Examples Using Clustering Techniques
Java In-Process Caching - Performance, Progress and Pitfalls
Java In-Process Caching - Performance, Progress and Pittfalls
Caching and tuning fun for high scalability
maxbox starter60 machine learning
Performance is a Feature! at DDD 11
Ad

More from Max Kleiner (20)

PDF
EKON28_ModernRegex_12_Regular_Expressions.pdf
PDF
EKON28_Maps_API_12_google_openstreetmaps.pdf
PDF
EKON26_VCL4Python.pdf
PDF
EKON26_Open_API_Develop2Cloud.pdf
PDF
maXbox_Starter91_SyntheticData_Implement
PDF
Ekon 25 Python4Delphi_MX475
PDF
EKON 25 Python4Delphi_mX4
PDF
maXbox Starter87
PDF
maXbox Starter78 PortablePixmap
PDF
maXbox starter75 object detection
PDF
BASTA 2020 VS Code Data Visualisation
PDF
EKON 24 ML_community_edition
PDF
maxbox starter72 multilanguage coding
PDF
EKON 23 Code_review_checklist
PDF
EKON 12 Running OpenLDAP
PDF
EKON 12 Closures Coding
PDF
NoGUI maXbox Starter70
PDF
maXbox starter69 Machine Learning VII
PDF
maXbox starter68 machine learning VI
PDF
maXbox starter67 machine learning V
EKON28_ModernRegex_12_Regular_Expressions.pdf
EKON28_Maps_API_12_google_openstreetmaps.pdf
EKON26_VCL4Python.pdf
EKON26_Open_API_Develop2Cloud.pdf
maXbox_Starter91_SyntheticData_Implement
Ekon 25 Python4Delphi_MX475
EKON 25 Python4Delphi_mX4
maXbox Starter87
maXbox Starter78 PortablePixmap
maXbox starter75 object detection
BASTA 2020 VS Code Data Visualisation
EKON 24 ML_community_edition
maxbox starter72 multilanguage coding
EKON 23 Code_review_checklist
EKON 12 Running OpenLDAP
EKON 12 Closures Coding
NoGUI maXbox Starter70
maXbox starter69 Machine Learning VII
maXbox starter68 machine learning VI
maXbox starter67 machine learning V
Ad

Recently uploaded (20)

PDF
Foundation of Data Science unit number two notes
PPTX
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
PDF
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PDF
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
PDF
Galatica Smart Energy Infrastructure Startup Pitch Deck
PPTX
Computer network topology notes for revision
PPTX
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
PDF
Business Analytics and business intelligence.pdf
PPT
Quality review (1)_presentation of this 21
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PDF
Lecture1 pattern recognition............
PDF
.pdf is not working space design for the following data for the following dat...
PPTX
Introduction to machine learning and Linear Models
PDF
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PPTX
Supervised vs unsupervised machine learning algorithms
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
Foundation of Data Science unit number two notes
Introduction to Basics of Ethical Hacking and Penetration Testing -Unit No. 1...
“Getting Started with Data Analytics Using R – Concepts, Tools & Case Studies”
IBA_Chapter_11_Slides_Final_Accessible.pptx
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
Galatica Smart Energy Infrastructure Startup Pitch Deck
Computer network topology notes for revision
iec ppt-1 pptx icmr ppt on rehabilitation.pptx
Business Analytics and business intelligence.pdf
Quality review (1)_presentation of this 21
Introduction to Knowledge Engineering Part 1
Business Ppt On Nestle.pptx huunnnhhgfvu
Lecture1 pattern recognition............
.pdf is not working space design for the following data for the following dat...
Introduction to machine learning and Linear Models
168300704-gasification-ppt.pdfhghhhsjsjhsuxush
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
Supervised vs unsupervised machine learning algorithms
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj

Ekon22 tensorflow machinelearning2

  • 2. 2 TensorFlow Agenda 2https://www.esecurityplanet.com/views/article.php/1501001/Security-Threat-Correlation-The-Next-Battlefield.htm  3 Cases – XOR, MNIST, Image Cluster with QT 5 Sacred Experiment Log Recorder Most experiments score with metrics as confusion matrix  What's behind TF ? (pattern recognition)  Cluster & Classify with different inputs, params, config Define label or topic ratings, hyper-parameters, – assumed/implicit labels, predict versus target  Conclusions/ ML Data-mining Summary/
  • 3. CASSANDRASystem 3 What is TensorFlow? Intro Link to EuroPython  Probabilistic (NB, MNB, PD, BN, BC, PLSA, LDA, ...)  Independence assumptions made  Stochastic or Distance-based (SVM, matching, VSIM, k- NN,CR, PageRank,Kmeans)  Features used  Structures exploited  Model-based (rules, BC, BN, boosting)  Social media driven
  • 4. 4 4 https://www.springboard.com/blog/data-mining-python-tutorial/ Baseline Perceptron (MLP) with XOR C:maXboxBASTA2018xor_perceptron.py http://playground.tensorflow.org_maXbox1 http://playground.tensorflow.org_maXbox2
  • 7. CASSANDRASystem 7 from keras.datasets import mnist 0 1 2 3 4 5 6 7 8 9  76 english, 38 content="voa,  36 美国之音 " 74 special hand written  44 Modified National Institute of Standards and Technology database)  36 голос 36 америки The MNIST dataset is comprised of 70,000 handwritten numeric digit images and their respective labels 0..9. 2. Main: C:maXboxmX46210DataScienceplot_confusion_matrix_vectormachine.py 3. Second C:maXboxmX46210DataScienceconfusionlistmnist_softmax21.py https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/4_Utils/tensorboard_basic.ipynb There are 60,000 training images and 10,000 test images, all of which are 28 pixels by 28 pixels.
  • 8. CASSANDRASystem 8 QT from keras import backend as K @ex.automain def define_and_train(batch_size, epochs, convolution_layers, maxpooling_pool_size, maxpooling_dropout, dense_layers, dense_dropout, final_dropout,_run): from keras.models import Sequential #convolution from keras.layers import Dense, Dropout, Flatten, Conv2D, from keras.utils import to_categorical from keras.losses import categorical_crossentropy from keras.optimizers import Adadelta from keras import backend as K from keras.callbacks import ModelCheckpoint, Callback 4. C:maXboxmX46210ntwdblib.dllUnsharpDetector-masterUnsharpDetector-masterinference_gui.py
  • 9. CASSANDRASystem 9 MongoDB/Sacred module import class 0 1 2 3 4 5 6 7 8 9 from __future__ import division, print_function, unicode_literals from sacred import Experiment from sacred.observers import MongoObserver from sacred.utils import apply_backspaces_and_linefeeds import pymongo, pickle, os import pydot as pdot import numpy as np import tensorflow as tf 5. C:maXboxmX46210DataScienceconfusionlisttrain_convnet_tf.py
  • 10. CASSANDRASystem 10 MongoDB  Start the shell process mongod from  Call from script or start mongod: C:Program FilesMongoDBServer3.6bin>mongod
  • 11. CASSANDRASystem 11 MongoDB My Cluster sacred.runs & completed
  • 16. 16 16 What's behind test ? (backend pattern, crossentropy) 60000/60000 [==============================] - 426s 7ms/step - loss: 0.4982 - acc: 0.8510 - val_loss: 0.0788 - val_acc: 0.9749 Using TensorFlow backend. INFO - MNIST-Convnet4 - Result: 0.9749 INFO - MNIST-Convnet4 - Completed after 0:07:27 Test loss: 0.0788029053777 Test accuracy: 0.9749  59392/60000 [============================>.] - ETA: 5s - loss: 0.0571 - acc: 0.9829  59520/60000 [============================>.] - ETA: 3s - loss: 0.0572 - acc: 0.9829  59648/60000 [============================>.] - ETA: 2s - loss: 0.0572 - acc: 0.9829  59776/60000 [============================>.] - ETA: 1s - loss: 0.0572 - acc: 0.9829  59904/60000 [============================>.] - ETA: 0s - loss: 0.0573 - acc: 0.9829  60000/60000 [==============================] - 513s 9ms/step - loss: 0.0573 - acc: 0.9829 - val_loss: 0.0312 - val_acc: 0.9891  Using TensorFlow backend.  INFO - MNIST-Convnet4 - Result: 0.9891  INFO - MNIST-Convnet4 - Completed after 0:33:28  Test loss: 0.0311644290059  Test accuracy: 0.9891 
  • 17. 17 17 What's behind code ? (keras, pymongo, pydot, graphviz) db = pymongo.MongoClient('mongodb://localhost:27017/').sacred print(tf.__version__) os.environ["PATH"] += os.pathsep + 'C:/Program Files (x86)/Graphviz2.38/bin/' from tensorflow.examples.tutorials.mnist import input_data ex = Experiment("MNIST-Convnet4") ex.observers.append(MongoObserver.create()) ex.captured_out_filter = apply_backspaces_and_linefeeds https://www.programcreek.com/python/example/103267/keras.datasets.mnist.load_data
  • 18. 18 18https://github.com/pinae/Sacred-MNIST/blob/master/train_convnet.py Whats behind 64-bit Python: PIP3 Install pip3 install sacred Collecting sacred Downloading https://files.pythonhosted.org/packages/2d/86/7be3af a4d4c1c0c76a5de03e5ff779797ab2654e377685255c11c13c0e a5/sacred-0.7.3-py2.py3-none-any.whl (82kB) Collecting pymongo Downloading https://files.pythonhosted.org/packages/46/39/b9bb7fed3e3a0ea621a1 512a938c105cd996320d7d9894d8239ca9093340/pymongo-3.6.1-cp36-cp36m- win_amd64.whl (291kB) 100% |¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦| 296kB 728kB/s Installing collected packages: pymongo Successfully installed pymongo-3.6.1
  • 19. 19 19 Machine Learning Jokes ;-) 1. There are two kinds of data scientists: 1) Those who can extrapolate from incomplete data. 2. In data science, 80 percent of time spent is preparing data, 20 percent of time is spent complaining about the need to prepare data. https://maxbox4.wordpress.com/ http://www.softwareschule.ch/examples/machinelearning.jpg
  • 20. CASSANDRASystem 20 https://www.kaggle.com/ similarity of doc a to doc b = '' )',( ),( )',( ),( ),( word ' 2 ' 2 BA jbv jbv jav jav basim i jj    