ECE521 W17 Tutorial 1. Renjie Liao & Min Bai

Similar documents
INF 5860 Machine learning for image classification. Lecture 5 : Introduction to TensorFlow Tollef Jahren February 14, 2018

(Artificial) Neural Networks in TensorFlow

(Artificial) Neural Networks in TensorFlow

TensorFlow: A Framework for Scalable Machine Learning

Pytorch Tutorial. Xiaoyong Yuan, Xiyao Ma 2018/01

Crash Course on TensorFlow! Vincent Lepetit!

@SoyGema GEMA PARREÑO PIQUERAS

CSC321 Lecture 2: Linear Regression

CSC 411 Lecture 6: Linear Regression

TensorFlow. Dan Evans

More on Neural Networks

Introduction to TensorFlow

DS Machine Learning and Data Mining I. Alina Oprea Associate Professor, CCIS Northeastern University

Experiment 1: Linear Regression

Scikit-learn. scikit. Machine learning for the small and the many Gaël Varoquaux. machine learning in Python

2 Getting Started with Numerical Computations in Python

Introduction to Deep Learning CMPT 733. Steven Bergner

Lectures about Python, useful both for beginners and experts, can be found at (

Math for ML: review. CS 1675 Introduction to ML. Administration. Lecture 2. Milos Hauskrecht 5329 Sennott Square, x4-8845

Tensor Flow. Tensors: n-dimensional arrays Vector: 1-D tensor Matrix: 2-D tensor

Machine Learning Basics

Linear Algebra (Review) Volker Tresp 2017

Department of Chemical Engineering University of California, Santa Barbara Spring Exercise 2. Due: Thursday, 4/19/09

B553 Lecture 5: Matrix Algebra Review

A Practitioner s Guide to MXNet

Lecture 2: Linear regression

ECE521: Inference Algorithms and Machine Learning University of Toronto. Assignment 1: k-nn and Linear Regression

Linear Algebra (Review) Volker Tresp 2018

Python & Numpy A tutorial

Lecture 35: Optimization and Neural Nets

A Tutorial On Backward Propagation Through Time (BPTT) In The Gated Recurrent Unit (GRU) RNN

A Quick Tour of Linear Algebra and Optimization for Machine Learning

Review: Linear and Vector Algebra

4 Linear Algebra Review

IFT 6760A - Lecture 1 Linear Algebra Refresher

Vectorization. Yu Wu, Ishan Patil. October 13, 2017

introduction to convolutional networks using tensorflow

Machine learning comes from Bayesian decision theory in statistics. There we want to minimize the expected value of the loss function.

Introduction to TensorFlow

MATHEMATICAL OBJECTS in

Math for ML: review. Milos Hauskrecht 5329 Sennott Square, x people.cs.pitt.edu/~milos/courses/cs1675/

Image Processing in Numpy

Learning Deep Architectures for AI. Part II - Vijay Chakilam

CS Deep Reinforcement Learning HW2: Policy Gradients due September 19th 2018, 11:59 pm

ECE521 Lectures 9 Fully Connected Neural Networks

Quantum Computing Lecture 2. Review of Linear Algebra

Python. Tutorial. Jan Pöschko. March 22, Graz University of Technology

Mustafa Jarrar. Machine Learning Linear Regression. Birzeit University. Mustafa Jarrar: Lecture Notes on Linear Regression Birzeit University, 2018

HOMEWORK #4: LOGISTIC REGRESSION

EE-559 Deep learning 1.4. Tensor basics and linear regression. François Fleuret Mon Mar 18 20:04:34 UTC 2019

Appendix 2: Linear Algebra

MODELS USING MATRICES WITH PYTHON

SPARSE TENSORS DECOMPOSITION SOFTWARE

Math for ML: review. ML and knowledge of other fields

Welcome to the Machine Learning Practical Deep Neural Networks. MLP Lecture 1 / 18 September 2018 Single Layer Networks (1) 1

Lab 2 Worksheet. Problems. Problem 1: Geometry and Linear Equations

Neural Networks, Computation Graphs. CMSC 470 Marine Carpuat

Optimization for Machine Learning

Managing Uncertainty

ECS130 Scientific Computing. Lecture 1: Introduction. Monday, January 7, 10:00 10:50 am

STA141C: Big Data & High Performance Statistical Computing

b 1 b 2.. b = b m A = [a 1,a 2,...,a n ] where a 1,j a 2,j a j = a m,j Let A R m n and x 1 x 2 x = x n

January 18, 2008 Steve Gu. Reference: Eta Kappa Nu, UCLA Iota Gamma Chapter, Introduction to MATLAB,

SECTION 2: VECTORS AND MATRICES. ENGR 112 Introduction to Engineering Computing

Math 307 Learning Goals. March 23, 2010

LEC1: Instance-based classifiers

ECS289: Scalable Machine Learning

MATH36061 Convex Optimization

Machine Learning. Boris

The File Geodatabase API. Craig Gillgrass Lance Shipman

Linear models: the perceptron and closest centroid algorithms. D = {(x i,y i )} n i=1. x i 2 R d 9/3/13. Preliminaries. Chapter 1, 7.

Classification of Hand-Written Digits Using Scattering Convolutional Network

CS 231A Section 1: Linear Algebra & Probability Review

Theano: A Few Examples

CS 231A Section 1: Linear Algebra & Probability Review. Kevin Tang

Deep Learning. Convolutional Neural Networks Applications

Intro Vectors 2D implicit curves 2D parametric curves. Graphics 2012/2013, 4th quarter. Lecture 2: vectors, curves, and surfaces

Review Packet 1 B 11 B 12 B 13 B = B 21 B 22 B 23 B 31 B 32 B 33 B 41 B 42 B 43

Geometric View of Machine Learning Nearest Neighbor Classification. Slides adapted from Prof. Carpuat

Background Mathematics (2/2) 1. David Barber

INNER PRODUCT SPACE. Definition 1

Neural Networks and Deep Learning

CS 143 Linear Algebra Review

This appendix provides a very basic introduction to linear algebra concepts.

High-Performance Scientific Computing

Deep Learning 101 a Hands-on Tutorial

Introduction to Logistic Regression

Introduction to Python

NumPy 1.5. open source. Beginner's Guide. v g I. performance, Python based free open source NumPy. An action-packed guide for the easy-to-use, high

Ohio s Learning Standards-Extended. Mathematics. The Real Number System Complexity a Complexity b Complexity c

Outline Python, Numpy, and Matplotlib Making Models with Polynomials Making Models with Monte Carlo Error, Accuracy and Convergence Floating Point Mod

CPSC 540: Machine Learning

Vector Spaces. Commutativity of +: u + v = v + u, u, v, V ; Associativity of +: u + (v + w) = (u + v) + w, u, v, w V ;

Linear Algebra Review. Vectors

Python Raster Analysis. Kevin M. Johnston Nawajish Noman

Introduction. How to use this book. Linear algebra. Mathematica. Mathematica cells

Computational Graphs, and Backpropagation

DEPARTMENT OF COMPUTER SCIENCE AUTUMN SEMESTER MACHINE LEARNING AND ADAPTIVE INTELLIGENCE

Linear Algebra. Maths Preliminaries. Wei CSE, UNSW. September 9, /29

Basic Linear Algebra in MATLAB

Transcription:

ECE521 W17 Tutorial 1 Renjie Liao & Min Bai

Schedule Linear Algebra Review Matrices, vectors Basic operations Introduction to TensorFlow NumPy Computational Graphs Basic Examples

Linear Algebra Review Vector: 1D array, row, column vectors Matrix: 2D array

Vector Addition, Scalar Multiplication

Vector Inner Product Properties: Conjugate Symmetry Linearity Positive-Definiteness

Vector Outer Product

Vector Norms Lp Norm: Example: For p = 1: Manhattan norm For p = 2: Euclidean norm

Geometric Interpretation

Matrix Addition, Scalar Multiplication

Broadcasting

Matrix Multiplication

Matrix Multiplication

Matrix Multiplication Properties: Not Commutative (In general) Distributive Transpose

Matrix Vector Multiplication Row/Column views

1D Convolution Discrete Definition: Continuous Definition

1D Visualization

2D Convolution

Convolution as Matrix Multiplication

Convolution as Matrix Multiplication

Convolution as Matrix Multiplication

Introduction to TensorFlow What is it? Open source library by Google for machine learning Supports CPU / GPU / mix / distributed computing Linux, Mac OS X, Windows versions How to get it? https://www.tensorflow.org/get_started/os_setup https://github.com/tensorflow/tensorflow

NumPy Important python package, core component of TensorFlow Similar supports linear algebra and numerical operations similar to MATLAB Part of larger SciPy package which has even more numerical operations

NumPy and TensorFlow Comparisons Credit: Stanford CS224 Lecture Notes

TensorFlow Overview Unlike NumPy, TensorFlow does NOT perform operations immediately Need to explicitly run operation Represents data as multidimensional arrays, or tensors Basic procedure: Construct computational graph Create an operations session Initialize parameters of computational graph, if any (eg initial model weights) Feed data to graph (eg input image matrix) Execute computation operations which return data (eg output label for object in image)

TensorFlow - Basic Example 1 An example of the element-wise product of two vectors:

TensorFlow - Basic Example 1 Construct computational graph Note that c does NOT actually have a value The graph defines operational relationships between nodes Note that in this case, c has inferred the shape to be (4,) - but a node can have None as dimensions if unknown at construction time the resulting computation graph

TensorFlow - Basic Example 1 Create operations session: or Session defines an environment for the execution of operations The session keeps track of a set of actual values for variable nodes Can have multiple sessions to run copies of graphs in parallel tf.interactivesession() often used in ipython to set current session as default

TensorFlow - Basic Example 1 Initialize parameters in graph: Execute computation graph: Returns values for each node queried

TensorFlow - Basic Example 1

TensorFlow - Basic Example 2 Example 1 does not have a feeding mechanism Suppose we want to: All parameters in the graph were available in advance Define the graph Initialize nodes that correspond to model parameters - ONLY ONCE! Provide training data to some nodes and update model parameters via gradient descent We use the tf.placeholder() Arguments: data type (mandatory), shape (optional), name (optional) Specifying (the entirety or part of) shape restricts shapes of possible inputs to the node At run time, we feed using a feed_dict

TensorFlow - Basic Example 2

TensorFlow - Basic Example 3 The most important operation: optimization Define a loss function Select an optimizer https://www.tensorflow.org/api_docs/python/train/ Define optimization operation using selected optimizer sess.run(optimization operation) elementsquarederror = tf.square(y_predicted-y_target) meansquarederror = tf.reduce_mean(tf.reduce_sum(elementsquarederror, reduction_indices=1)) optimizer = tf.train.gradientdescentoptimizer(learning_rate=0.005) train = optimizer.minimize(loss=meansquarederror) sess.run(train)

TensorFlow - Basic Example 3 Example: is a 100 by 5 matrix (100 sets of 5-dimensional input data points) is a 1 by 100 target vector (100 target labels for each x) W is a 5 by 1 weights vector b is a scalar Model: Given X and Y, optimize for W and b under mean squared error over the 70 training examples: Example code at: http://www.psi.toronto.edu/~jimmy/ece521/mult.py Also download the two dataset files http://www.psi.toronto.edu/~jimmy/ece521/x.npy http://www.psi.toronto.edu/~jimmy/ece521/t2.npy

TensorFlow - Basic Example 3 Automatic differentiation in TensorFlow can generate gradient of a computation graph with respect to the variables automatically.