Skip to document

1.2 Software Frameworks

junior
Course

english 101 (Eng101)

14 Documents
Students shared 14 documents in this course
Academic year: 2021/2022
Uploaded by:
0followers
9Uploads
1upvotes

Comments

Please sign in or register to post comments.

Preview text

1

Software Frameworks for

Machine Learning

Sargur N. Srihari

srihari@cedar.buffalo

Topics

" Python

" Python versus C++

" ML Frameworks

" Tensorflow

2

Example of Python Code

" Problem: Count no of vowels in string

Assume s is a string of lower case characters. Write a program that counts up the number of vowels contained in the string s. Valid vowels are: 'a', 'e', 'i', 'o', and 'u’. For example, if s = 'azcbobobegghakl', your program should print: Number of vowels: 5

" Code is given next

3 See 3 medium/cyberdoggo/mit-6-00-1x-problem-set-1-c5ba79ae2aad 4

Python Code for vowel count

variable s is predefineddefine and set variable vowelCount to 0

vowelCount = 0

create a for loop to iterate through each character of s

for letter in s: # if letter in s equal to each vowel, increment vowelCount by 1 if letter == "a": vowelCount += 1 elif letter == "e": vowelCount += 1 elif letter == "i": vowelCount += 1 elif letter == "o": vowelCount += 1 elif letter == "u": vowelCount += 1

print the concatenated first string and vowelCount

print("Number of vowels: " + str(vowelCount)) 5

Python vs C++

" FizzBuzz:

3 Print i= 1 to 100 , except:

" if divisible by 3 print fizz, " if divisible by 5 print buzz, " if divisible by both 3 and 5 print fizzbuzz

" Code in C++ and Python:

C++: Python:

1

Python Interpreted language, emphasizes code readabilityfewer lines of code than C++orJava NumPy an extension toPython: library of functions to operate on arrays.

What are ML frameworks?

" Frameworks offer building blocks for designing,

training and validating deep neural networks,

through a high level programming interface

3 Optimized for performance

3 Provide parallelization for implementation on GPUs

3 Visualization of network modeling and interface

8

Machine Learning Frameworks

10

Machine Learning Srihari

Framework differences

1. Theano (terminated in 2018 )

  • NumPy-like numerical computation for CPU/GPUs

2. Tensorflow (Google)

3 Large-scale deployment (cross-platform, embedded)

3. PyTorch (Facebook)

3 GPU enabled drop-in replacement for NumPy

3 For rapid prototyping

3 Dynamic computational graphs

4. Gluon (AWS, Microsoft)

3 Model and training algorithms brought closer,

3 High performance training

1 1

PyTorch vs TensorFlow

• PyTorch is better for rapid prototyping in

research, for hobbyists and for small scale

projects.

" TensorFlow is better for large-scale

deployments, especially when cross-platform

and embedded deployment is a consideration

" See awni.github/pytorch-tensorflow/

13

Keras

" Keras is a higher-level API with a configurable back-end. IN 2018 TensorFlow, Theano and CNTK are supported not PyTorch. " Keras is also distributed with TensorFlow as a part of tf. " Keras API is especially easy to use. It9s one of the fastest ways to get running with many of the more commonly used deep neural network architectures. 3 API is not as flexible as PyTorch or core TensorFlow.

14

Natural Language Toolkit

" Import nltk

" Moby=nltk.text(nltk.corpus.

words(8melville-moby_dick))

" print(moby_contexts(<ahab=)

16

Machine Learning Srihari

Fizzbuzz using a simple MLP

3 Given supervised output

3 As a simple MLP with one hidden layer

1 7

Input X: D=10 (i represented by 10 bits) No. of hidden units: M=1, Output Y: K=4 (One-hot vector with 4 values)

1,2,Fizz,4,Buzz,7,8,Fizz,Buzz,11,Fizz,13,14,FizzBuzz,16,17,&

Computational Graph

" Network structure specified

by computational graphs

" Makes it easy to visualize

and debug

19

Tensorboard Visualization

Machine Learning Srihari

Fizzbuzz in Tensorflow

" Import numpy and Tensorflow libraries

import numpy as np import tensorflow as tf

2 0

Was this document helpful?

1.2 Software Frameworks

Course: english 101 (Eng101)

14 Documents
Students shared 14 documents in this course
Was this document helpful?
Machine Learning Srihari
1
Software Frameworks for
Machine Learning
Sargur N. Srihari
srihari@cedar.buffalo.edu