Implement NN using NumPy

Size: px
Start display at page:

Download "Implement NN using NumPy"

Transcription

1 Implement NN using NumPy Hantao Zhang Deep Learning with Python Reading: Recommendation for Using Python Install anaconda on your PC. If you already have installed anaconda, remember to update: conda update all Use spyder in anaconda. See 2 1

2 Numerical Python (Numpy) NumPy is at the core of nearly every scientific Python application or module since it provides a fast N-d array datatype that can be manipulated in a vectorized form. Various views of multi-dimensional arrays It provides advanced array slicing methods (to select array elements) and convenient array reshaping methods Broadcast of operations to each element Making code compact and easy to read See 3 Numpy - ndarray NumPy's main object is the homogeneous multidimensional array called ndarray. This is a table of elements (usually numbers), all of the same type, indexed by a tuple of positive integers. Typical examples of multidimensional arrays include vectors, matrices, images and spreadsheets. Dimensions usually called axes, number of axes is the rank [7, 5, -1] An array of rank 1, i.e., it has 1 axis of length 3 [ [ 1.5, 0.2, -3.7], An array of rank 2, i.e., it has 2 axes, the first [ 0.1, 1.7, 2.9] ] length 3, the second of length 3 (a matrix with 2 rows and 3 columns 2

3 Numpy array, broadcast In[1]: import numpy as np In[2]: a = np.array([1,2,3], float) In[3]: b = np.array([5,2,6], float) In[4]: a + b Out[4]: array([ 6., 4., 9.]) In[5]: a - b Out[5]: array([-4., 0., -3.]) In[6]: a * b Out[6]: array([ 5., 4., 18.]) In[7]: b**a Out[7]: array([ 5., 4., 216.]) In[8]: b**2 Out[8]: array([ 25., 4., 36.]) In[9]: a = np.array([[1, 2], [3, 4], [5, 6]], float) In[10]: b = np.array([-1, 3], float) In[1]1: a+b Out[11]: array([[ 0., 5.], [ 2., 7.], [ 4., 9.]]) In[12]: a*a Out[12]: array([[ 1., 4.], [ 9., 16.], [ 25., 36.]]) In[13]: a**2 Out[13]: array([[ 1., 4.], [ 9., 16.], [ 25., 36.]]) Numpy dot, shape, reshape, newaxis In[14]: v1 = np.array(range(0, 5)) In[15]: v2 = np.arange(5) In[16]: v1 Out[16]: array([0, 1, 2, 3, 4]) In[17]: v2 Out[17]: array([0, 1, 2, 3, 4]) In[18]: v1.dot(v2) Out[18]: 30 In[19]: np.dot(v1,v2) Out[19]: 30 In[20]: v1.shape Out[20]: (5,) In[21]: v3 = v1.reshape(1,5) In[22]: v3 Out[22]: array([[0, 1, 2, 3, 4]]) In[23]: v1[0] Out[23]: 0 In[24]: v3[0] Out[24]: array([0, 1, 2, 3, 4]) In[25]: v1[1] = 10 In[27]: v1 Out[27]: array([ 0, 10, 2, 3, 4]) In[28]: v3 Out[28]: array([[ 0, 10, 2, 3, 4]]) In[29]: v4 = v1[:, np.newaxis] In[30]: v4.shape Out[30]: (5, 1) In[31]: np.dot(v1,v4) Out[31]: array([30]) In[32]: np.dot(v3,v4) Out[32]: array([[30]]) In[33]: np.dot(v4,v3) Out[33]: array([[ 0, 0, 0, 0, 0], [ 0, 1, 2, 3, 4], [ 0, 2, 4, 6, 8], [ 0, 3, 6, 9, 12], [ 0, 4, 8, 12, 16]]) 3

4 Numpy Slicing ndarray In[1]: a = np.arange(9).reshape(3,3)+1 In[2]: a Out[2]: array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) In[3]: print(a[0]) Out[3]: [1 2 3] In[4]: print(a[1,2]) Out[4]: 6 In[5]: print(a[1,1:3]) Out[6]: [5 6] In[7]: print(a[:,1]) Out[7]: [2 5 8] In[8]: a[1,2] = 10 In[9]: a Out[9]: array([[ 1, 2, 3], [ 4, 5, 10], [ 7, 8, 9]]) In[10]: a[:,0] *= -1 In[11]: a Out[11]: array([[-1, 2, 3], [-4, 5, 10], [-7, 8, 9]]) In[12]: b = a.t In[13]: b Out[13]: array([[-1, -4, -7], [ 2, 5, 8], [ 3, 10, 9]]) In[14]: b[1,:] += 5 In[15]: b Out[15]: array([[-1, -4, -7], [ 7, 10, 13], [ 3, 10, 9]]) In[16]: a Out[80]: array([[-1, 7, 3], [-4, 10, 10], [-7, 13, 9]]) Numpy zeros, ones, rand In[30]: a = np.zeros(5) In[31]: b = np.ones(12) In[32]: a Out[32]: array([ 0., 0., 0., 0., 0.]) In[33]: b In[38]: m = np.random.rand(3,3) Out[33]: array([ 1., 1., 1.,..., In[39]: 1., m 1., 1.]) In[34]: c = b.reshape(3, 4) In[35]: c Out[35]: array([[ 1., 1., 1., 1.], [ 1., 1., 1., 1.], [ 1., 1., 1., 1.]]) In[36]: d = b.reshape(4, 3)+1 In[37]: d Out[37]: array([[ 2., 2., 2.], [ 2., 2., 2.], [ 2., 2., 2.], [ 2., 2., 2.]]) Out[39]: array([[ , , ], [ , , ], [ , , ]]) In[40]: n = np.dot(d, m) In[41]: n Out[42]: array([[ , , ], [ , , ], [ , , ], [ , , ]]) In[42]: n = np.dot(m, c) In[43]: n Out[44]: array([[ , , , ], [ , , , ], [ , , , ]]) 4

5 Numpy ndarray attributes ndarray.ndim the number of axes (dimensions) of the array i.e. the rank. ndarray.shape the dimensions of the array. This is a tuple of integers indicating the size of the array in each dimension. For a matrix with n rows and m columns, shape will be (n,m). The length of the shape tuple is therefore the rank, or number of dimensions, ndim. ndarray.size the total number of elements of the array, equal to the product of the elements of shape. ndarray.dtype an object describing the type of the elements in the array. One can create or specify dtype's using standard Python types. NumPy provides many, for example bool_, character, int_, int8, int16, int32, int64, float_, float8, float16, float32, float64, complex_, complex64, object_. ndarray.itemsize the size in bytes of each element of the array. E.g. for elements of type float64, itemsize is 8 (=64/8), while complex32 has itemsize 4 (=32/8) (equivalent to ndarray.dtype.itemsize). ndarray.data the buffer containing the actual elements of the array. Normally, we won't need to use this attribute because we will access the elements in an array using indexing facilities. Numpy sum, mean, max, min, transpose In[46]: arr = np.arange(10, 20). reshape(2,5) In[47]: arr Out[47]: array([[10, 11, 12, 13, 14], [15, 16, 17, 18, 19]]) In[48]: arr.sum() Out[48]: 145 In[49]: arr.mean() Out[49]: 14.5 In[50]: arr.max() Out[50]: 19 In[51]: np.sum(arr**2) Out[51]: 2185 In[52]: arr.t Out[52]: array([[10, 15], [11, 16], [12, 17], [13, 18], [14, 19]]) 5

6 Using Numpy arrays wisely Array operations are implemented in C or Fortran Optimized algorithms - i.e. fast! Python loops (i.e. for i in a: ) are much slower Prefer array operations over loops, especially when speed is important It also produces shorter code, often more readable mlnn.py The major features: 1. Provides a general, fully connected, multi layer neural network, 2. The cost function is quadratic error, though replaceable. 3. The activation function can be changed in the constructor 4. The mini patch size is a parameter 5. An epoch is roughly using every training example exactly once. 6

7 mlnn.py from sklearn.utils import shuffle import numpy from matplotlib.colors import ListedColormap import matplotlib.pyplot as plt def square_cost(actual_output, y): "" Return the sum of square cost, where y is the desired output. """ return np.sum((actual_output - y)**2)/2 def square_cost_derivative(actual_output, y): "" Return the partial derivatives of the cost function for the actual output. """ return (actual_output - y) mlnn.py def sigmoid(x): """The sigmoid function.""" return 1.0/(1.0+np.exp(-x)) def sigmoid_prime(x, y): """Derivative of the sigmoid function.""" return y*(1-y) def tanh(x): """ the hyperbolic tangent function """ return (1.0 - np.exp(-2*x))/(1.0 + np.exp(-2*x)) def tanh_prime(x, y): """ the derivative of hyperbolic tangent function """ return (1 + y)*(1 - y) 7

8 Computation in General NN There are L layers, l {1, 2,, L} plus input layer (l = 0); each layer is fully connected to the next. An example of 4-layer NN: 4 weight matrices: W 0 W 1 W 2 W 3 W i [j,k] = link weight from j th neuron in layer i to k th neuron in layer (i+1) 4 outputs: y 0 y 1 y 2 y 3 y 4 (plus y 0 x, the input) 4 sums: y 0 z 0 y 1 z 1 y 2 z 2 y 3 z 3 y 4 z i = y i W i + b i z i [j] = y[0]w[0, j] + y[1]w[1, j] + + y[r-1]w[r-1, j] + b i [j] where y = y i, W=W i, and r is the row number of W i y i+1 = a(z i ), where a is the activation function. Computation in General NN There are L layers, l {1, 2,, L} plus input layer (l = 0); each layer is fully connected to the next. An example of 4-layer NN: 4 weight matrices: W 0 W 1 W 2 W 3 W i [j,k] = link weight from j th neuron in layer i to k th neuron in layer (i+1) 4 outputs: y 0 y 1 y 2 y 3 y 4 (plus y 0 x, the input) 4 sums: y 0 z 0 y 1 z 1 y 2 z 2 y 3 z 3 y 4 z i = y i W i + b i z i [j] = y[0]w[0, j] + y[1]w[1, j] + + y[r-1]w[r-1, j] + b i [j] where y = y i, W=W i, and r is the row number of W i y i+1 = a(z i ), where a is the activation function. 8

9 class Network class Network: def init (self, net_arch): np.random.seed(60) # for reproducibility self.activation = sigmoid self.activation_derivative = sigmoid_prime # self.activation = tanh # self.activation_derivative = tanh_prime self.cost_derivative = square_cost_derivative self.num_layers = len(net_arch) - 1 self.sizes = net_arch self.weights = [np.random.randn(x, y) for x, y in zip(net_arch[:-1], net_arch[1:])] self.weights = np.asarray(self.weights) self.biases = np.asarray([np.random.randn(y) for y in net_arch[1:]]) Feed Forward Computation # It's simply feed forward computation. def feedforward(self, a): for w, b in zip(self.weights, self.biases): a = self.activation(np.dot(a, w) + b) return a # Training using backpropagation def SGD(self, train_x, train_y, epochs, batch_size, eta, test_data=none): # Plot the output of a binary function def plot_decision_regions(self, X, y, points=200): 9

10 XOR Example if name == ' main ': nn = Network(net_arch=[2,3,4,1]) print('net architecture:', nn.sizes) print('initial weights:\n', nn.weights) train_x = numpy.array([[0, 0], [0, 1], [1, 0], [1, 1]]) train_y = numpy.array([0, 1, 1, 0]) nn.sgd(train_x, train_y, 100, 1, 3) for a in train_x: print(a, nn.feedforward(a)) net.plot_decision_regions(train_x, train_y) # for binary input only Final prediction [0 0] [0 1] [1 0] [1 1] Computation in General NN There are L layers, l {1, 2,, L} plus input layer (l = 0); each layer is fully connected to the next. An example of 4-layer NN: 4 weight matrices: W 0 W 1 W 2 W 3 W i [j,k] = link weight from j th neuron in layer i to k th neuron in layer (i+1) 4 outputs: y 0 y 1 y 2 y 3 y 4 (plus y 0 x) 4 sums: y 0 z 0 y 1 z 1 y 2 z 2 y 3 z 3 y 4 z i = y i W i + b i a(z 0 ) = y 1 a(z 1 ) = y 2 a(z 2 ) = y 3 a(z 3 ) = y 4 y i+1 = a(z i ) 10

11 Backpropagation Multi-layer NN supervised learning Use Gradient Decent, and require differentiable activation and cost functions Error is propagated back through earlier layers Main Idea: Given a set of input/output examples { (x, y) }. Define the network as a function f(w, x) on weights w and x. Define the cost, say C = ½ f(w,x) y 2, and try to minimalize it. For each example (x, y), repeat the following: 1. compute f(w, x) 2. compute C/ w 3. update w by w = w ( C/ w) to decrease C. Computation in General NN There are L layers, l {1, 2,, L} plus input layer (l = 0); each layer is fully connected to the next. An example of 4-layer NN: Define C ½ (y L y) 2, i C/ y i, i C/ z i, then we have L = (y L y) i = a (z i ) i+1 i = W i i 4 weight matrices: W 0 W 1 W 2 W 3 W i [k,j] = link weight from k th neuron in layer i to j th neuron in layer (i+1) 4 outputs: y 0 y 1 y 2 y 3 y 4 (plus y 0 = x) 4 sums: y 0 z 0 y 1 z 1 y 2 z 2 y 3 z 3 y 4 z i = y i W i, y i+1 = a(z i ) 4 i & i : From z i [j] = y i [0]W i [0, j] + y i [1]W i [1, j] + + y i [r-1]w i [r-1, j] + b i [j] we have C/ b i = C/ z i = i, C/ W i [k,j] = y i [k]( C/ z i [j]) (or C/ W i = (y i 1) (1 i )) 11

12 Proof of i = W i i for i = L 1,, 2, 1 There are L layers, l {1, 2,, L} plus input layer (l = 0); each layer is fully connected to the next. W i [j,k] = link weight from j th neuron in layer i to k th neuron in layer (i+1) Assume z i = y i W i, i C/ y i, i C/ z i, L = (y L y), i = i+1 a (z i ). Assume also i is dropped from z i, y i, W i, i, z i for convenience: = W means i = W i i, equivalent to [j] = k W[j, k] [k] for all j. C/ y means i C/ y i, equivalent to [k] = C/ y[k] for all k. From z i = y i W i, we have z[k] = j y[j]w[j,k] and z[k]/ y[j] = W[j,k]. Hence [j] = C/ y[j] = k ( z[k]/ y[j])( C/ z[k]) = k W[j,k] [k], that is the same as [j] = k W[j, k] [k]. So = W. Note: From z i = y i W i, we get i = W i i. Here, W i serves dual roles: function h, where z i = h(y i ) and Jacobian matrix z/ y. That is the case for all linear function h. See z i = y i W i, y i+1 = a(z i ) C ½ (y L y) 2, i C/ y i, i C/ z i L = (y L y), i = a (z i ) i+1 and i = W i i C/ b i = i, C/ W i = (y i 1) (1 i ) def backprop(self, x, y): # feedforward y_act = x # y0 = x, the input y_acts = [x] # list to store all the activation vectors, y s, layer by layer z_wsums = [] # list to store all the weighted sum vectors, layer by layer for b, w in zip(self.biases, self.weights): z = np.dot(y_act, w) + b z_wsums.append(z) y_act = self.activation(z) y_acts.append(y_act) # backward propagation # nabla1: place holder for all layers of weights and biases nabla1_b = list(range(self.num_layers)) nabla1_w = list(range(self.num_layers)) 12

13 mnist.pkl.gz z i = y i W i, y i+1 = a(z i ) C ½ (y L y) 2, i C/ y i, i C/ z i L = (y L y), i = a (z i ) i+1, and i = W i i C/ b i = i, C/ W i = (y i 1) (1 i ) def backprop(self, x, y): # backward propagation theta = self.cost_derivative(y_act, y) delta = self.activation_derivative(z, y_act) * theta y_hat = np.expand_dims(y_acts[-2], axis=1) delta_hat = np.expand_dims(delta, axis=0) nabla1_w[-1] = np.dot(y_hat, delta_hat) nabla1_b[-1] = delta for l in range(2, self.num_layers+1): theta = np.dot(self.weights[-l+1], delta) delta = self.activation_derivative(z_wsums[-l], y_acts[-l]) * theta y_hat = np.expand_dims(y_acts[-l-1], axis=1) delta_hat = np.expand_dims(delta, axis=0) nabla1_w[-l] = np.dot(y_hat, delta_hat) nabla1_b[-l] = delta return (nabla1_b, nabla1_w) z i = y i W i, y i+1 = a(z i ) C ½ (y L y) 2, i C/ y i, i C/ z i L = (y L y), i = a (z i ) i+1, and i = W i i C/ b i = i, C/ W i = (y i 1) (1 i ) def update_batch(self, batch_x, batch_y, eta): nabla_w = np.zeros(self.weights.shape) nabla_b = np.zeros(self.biases.shape) for x, y in zip(batch_x, batch_y): nabla1_b, nabla1_w = self.backprop(x, y) nabla_w = nabla_w + nabla1_w nabla_b = nabla_b + nabla1_b self.weights -= eta*nabla_w self.biases -= eta*nabla_b # an alternative: # self.weights -= eta*nabla_w / batch_size # self.biases -= eta*nabla_b / batch_size 13

14 def SGD(self, train_x, train_y, epochs, batch_size, eta, test_data=none): n = len(train_x) if test_data: n_test = len(test_data[0]) for j in range(epochs): # stochastic requires to create random batches. train_x, train_y = shuffle(train_x, train_y) batches_x = [train_x[k : k+batch_size] for k in range(0, n, batch_size)] batches_y = [train_y[k : k+batch_size] for k in range(0, n, batch_size)] batches_x = np.asarray(batches_x) batches_y = np.asarray(batches_y) for batch_x, batch_y in zip(batches_x, batches_y): self.update_batch(batch_x, batch_y, eta) if test_data: print("epoch {} : {} / {}".format(j, self.evaluate(test_data), n_test)); 14

SGD: Stochastic Gradient Descent

SGD: Stochastic Gradient Descent Improving SGD Hantao Zhang Deep Learning with Python Reading: http://neuralnetworksanddeeplearning.com/index.html Chapter 2 SGD: Stochastic Gradient Descent Main Idea: Given a set of input/output examples

More information

Phys Techniques of Radio Astronomy Part 1: Python Programming LECTURE 3

Phys Techniques of Radio Astronomy Part 1: Python Programming LECTURE 3 Phys 60441 Techniques of Radio Astronomy Part 1: Python Programming LECTURE 3 Tim O Brien Room 3.214 Alan Turing Building tim.obrien@manchester.ac.uk Tuples Lists and strings are examples of sequences.

More information

CSC Advanced Scientific Computing, Fall Numpy

CSC Advanced Scientific Computing, Fall Numpy CSC 223 - Advanced Scientific Computing, Fall 2017 Numpy Numpy Numpy (Numerical Python) provides an interface, called an array, to operate on dense data buffers. Numpy arrays are at the core of most Python

More information

Problem Based Learning 2018

Problem Based Learning 2018 Problem Based Learning 2018 Introduction to Machine Learning with Python L. Richter Department of Computer Science Technische Universität München Monday, Jun 25th L. Richter PBL 18 1 / 21 Overview 1 2

More information

Programming for Engineers in Python

Programming for Engineers in Python Programming for Engineers in Python Autumn 2016-17 Lecture 11: NumPy & SciPy Introduction, Plotting and Data Analysis 1 Today s Plan Introduction to NumPy & SciPy Plotting Data Analysis 2 NumPy and SciPy

More information

NumPy. Daniël de Kok. May 4, 2017

NumPy. Daniël de Kok. May 4, 2017 NumPy Daniël de Kok May 4, 2017 Introduction Today Today s lecture is about the NumPy linear algebra library for Python. Today you will learn: How to create NumPy arrays, which store vectors, matrices,

More information

Lezione 6. Installing NumPy. Contents

Lezione 6. Installing NumPy. Contents Lezione 6 Bioinformatica Mauro Ceccanti e Alberto Paoluzzi Dip. Informatica e Automazione Università Roma Tre Dip. Medicina Clinica Università La Sapienza Lab 01: Contents As with a lot of open-source

More information

NumPy. Computational Physics. NumPy

NumPy. Computational Physics. NumPy NumPy Computational Physics NumPy Outline Some Leftovers Get people on line! Write a function / Write a script NumPy NumPy Arrays; dexing; Iterating Creating Arrays Basic Operations Copying Linear Algebra

More information

Exercise: Introduction to NumPy arrays

Exercise: Introduction to NumPy arrays Exercise: Introduction to NumPy arrays Aim: Introduce basic NumPy array creation and indexing Issues covered: Importing NumPy Creating an array from a list Creating arrays of zeros or ones Understanding

More information

Weiguang Guan Code & data: guanw.sharcnet.ca/ss2017-deeplearning.tar.gz

Weiguang Guan Code & data: guanw.sharcnet.ca/ss2017-deeplearning.tar.gz Weiguang Guan guanw@sharcnet.ca Code & data: guanw.sharcnet.ca/ss2017-deeplearning.tar.gz Outline Part I: Introduction Overview of machine learning and AI Introduction to neural network and deep learning

More information

(DRAFT) PYTHON FUNDAMENTALS II: NUMPY & MATPLOTLIB

(DRAFT) PYTHON FUNDAMENTALS II: NUMPY & MATPLOTLIB (DRAFT) PYTHON FUNDAMENTALS II: NUMPY & MATPLOTLIB TROY P. KLING Contents 1. Importing Libraries 1 2. Introduction to numpy 2 3. Introduction to matplotlib 5 4. Image Processing 8 5. The Mandelbrot Set

More information

Chapter 5 : Informatics Practices. Class XII ( As per CBSE Board) Numpy - Array. New Syllabus Visit : python.mykvs.in for regular updates

Chapter 5 : Informatics Practices. Class XII ( As per CBSE Board) Numpy - Array. New Syllabus Visit : python.mykvs.in for regular updates Chapter 5 : Informatics Practices Class XII ( As per CBSE Board) Numpy - Array New Syllabus 2019-20 NumPy stands for Numerical Python.It is the core library for scientific computing in Python. It consist

More information

PYTHON NUMPY TUTORIAL CIS 581

PYTHON NUMPY TUTORIAL CIS 581 PYTHON NUMPY TUTORIAL CIS 581 VARIABLES AND SPYDER WORKSPACE Spyder is a Python IDE that s a part of the Anaconda distribution. Spyder has a Python console useful to run commands quickly and variables

More information

NumPy and SciPy. Lab Objective: Create and manipulate NumPy arrays and learn features available in NumPy and SciPy.

NumPy and SciPy. Lab Objective: Create and manipulate NumPy arrays and learn features available in NumPy and SciPy. Lab 2 NumPy and SciPy Lab Objective: Create and manipulate NumPy arrays and learn features available in NumPy and SciPy. Introduction NumPy and SciPy 1 are the two Python libraries most used for scientific

More information

NumPy Primer. An introduction to numeric computing in Python

NumPy Primer. An introduction to numeric computing in Python NumPy Primer An introduction to numeric computing in Python What is NumPy? Numpy, SciPy and Matplotlib: MATLAB-like functionality for Python Numpy: Typed multi-dimensional arrays Fast numerical computation

More information

Effective Programming Practices for Economists. 10. Some scientific tools for Python

Effective Programming Practices for Economists. 10. Some scientific tools for Python Effective Programming Practices for Economists 10. Some scientific tools for Python Hans-Martin von Gaudecker Department of Economics, Universität Bonn A NumPy primer The main NumPy object is the homogeneous

More information

Scientific Programming. Lecture A08 Numpy

Scientific Programming. Lecture A08 Numpy Scientific Programming Lecture A08 Alberto Montresor Università di Trento 2018/10/25 Acknowledgments: Stefano Teso, Documentation http://disi.unitn.it/~teso/courses/sciprog/python_appendices.html https://docs.scipy.org/doc/numpy-1.13.0/reference/

More information

Part VI. Scientific Computing in Python. Alfredo Parra : Scripting with Python Compact Max-PlanckMarch 6-10,

Part VI. Scientific Computing in Python. Alfredo Parra : Scripting with Python Compact Max-PlanckMarch 6-10, Part VI Scientific Computing in Python Compact Course @ Max-PlanckMarch 6-10, 2017 63 Doing maths in Python Standard sequence types (list, tuple,... ) Can be used as arrays Can contain different types

More information

Introduction to NumPy

Introduction to NumPy Lab 3 Introduction to NumPy Lab Objective: NumPy is a powerful Python package for manipulating data with multi-dimensional vectors. Its versatility and speed makes Python an ideal language for applied

More information

NumPy quick reference

NumPy quick reference John W. Shipman 2016-05-30 12:28 Abstract A guide to the more common functions of NumPy, a numerical computation module for the Python programming language. This publication is available in Web form1 and

More information

DEEP LEARNING IN PYTHON. The need for optimization

DEEP LEARNING IN PYTHON. The need for optimization DEEP LEARNING IN PYTHON The need for optimization A baseline neural network Input 2 Hidden Layer 5 2 Output - 9-3 Actual Value of Target: 3 Error: Actual - Predicted = 4 A baseline neural network Input

More information

python numpy tensorflow tutorial

python numpy tensorflow tutorial python numpy tensorflow tutorial September 11, 2016 1 What is Python? From Wikipedia: - Python is a widely used high-level, general-purpose, interpreted, dynamic programming language. - Design philosophy

More information

The SciPy Stack. Jay Summet

The SciPy Stack. Jay Summet The SciPy Stack Jay Summet May 1, 2014 Outline Numpy - Arrays, Linear Algebra, Vector Ops MatPlotLib - Data Plotting SciPy - Optimization, Scientific functions TITLE OF PRESENTATION 2 What is Numpy? 3rd

More information

Short Introduction to Python Machine Learning Course Laboratory

Short Introduction to Python Machine Learning Course Laboratory Pattern Recognition and Applications Lab Short Introduction to Python Machine Learning Course Laboratory Battista Biggio battista.biggio@diee.unica.it Luca Didaci didaci@diee.unica.it Dept. Of Electrical

More information

MS6021 Scientific Computing. TOPICS: Python BASICS, INTRO to PYTHON for Scientific Computing

MS6021 Scientific Computing. TOPICS: Python BASICS, INTRO to PYTHON for Scientific Computing MS6021 Scientific Computing TOPICS: Python BASICS, INTRO to PYTHON for Scientific Computing Preliminary Notes on Python (v MatLab + other languages) When you enter Spyder (available on installing Anaconda),

More information

Python Crash Course Numpy, Scipy, Matplotlib

Python Crash Course Numpy, Scipy, Matplotlib Python Crash Course Numpy, Scipy, Matplotlib That is what learning is. You suddenly understand something you ve understood all your life, but in a new way. Doris Lessing Steffen Brinkmann Max-Planck-Institut

More information

DSC 201: Data Analysis & Visualization

DSC 201: Data Analysis & Visualization DSC 201: Data Analysis & Visualization Arrays Dr. David Koop Class Example class Rectangle: def init (self, x, y, w, h): self.x = x self.y = y self.w = w self.h = h def set_corner(self, x, y): self.x =

More information

MLCV 182: Practical session 1 Ron Shapira Weber Computer Science, Ben-Gurion University

MLCV 182: Practical session 1 Ron Shapira Weber Computer Science, Ben-Gurion University MLCV 182: Practical session 1 Ron Shapira Weber Computer Science, Ben-Gurion University Getting Started There are two different versions of Python being supported at the moment, 2.7 and 3.6. For compatibility

More information

Derek Bridge School of Computer Science and Information Technology University College Cork

Derek Bridge School of Computer Science and Information Technology University College Cork CS4618: rtificial Intelligence I Vectors and Matrices Derek Bridge School of Computer Science and Information Technology University College Cork Initialization In [1]: %load_ext autoreload %autoreload

More information

LECTURE 19. Numerical and Scientific Packages

LECTURE 19. Numerical and Scientific Packages LECTURE 19 Numerical and Scientific Packages NUMERICAL AND SCIENTIFIC APPLICATIONS As you might expect, there are a number of third-party packages available for numerical and scientific computing that

More information

LECTURE 22. Numerical and Scientific Packages

LECTURE 22. Numerical and Scientific Packages LECTURE 22 Numerical and Scientific Packages NUMERIC AND SCIENTIFIC APPLICATIONS As you might expect, there are a number of third-party packages available for numerical and scientific computing that extend

More information

CS30 - Neural Nets in Python

CS30 - Neural Nets in Python CS30 - Neural Nets in Python We will experiment with neural networks using a simple software package written in Python. You can find the package at: http://www.cs.pomona.edu/~dkauchak/classes/cs30/assignments/assign6/cs30neural.txt

More information

Python for Scientists

Python for Scientists High level programming language with an emphasis on easy to read and easy to write code Includes an extensive standard library We use version 3 History: Exists since 1991 Python 3: December 2008 General

More information

Python Numpy (1) Intro to multi-dimensional array & numerical linear algebra. Harry Lee January 29, 2018 CEE 696

Python Numpy (1) Intro to multi-dimensional array & numerical linear algebra. Harry Lee January 29, 2018 CEE 696 Python Numpy (1) Intro to multi-dimensional array & numerical linear algebra Harry Lee January 29, 2018 CEE 696 Table of contents 1. Introduction 2. Linear Algebra 1 Introduction From the last lecture

More information

HW0 v3. October 2, CSE 252A Computer Vision I Fall Assignment 0

HW0 v3. October 2, CSE 252A Computer Vision I Fall Assignment 0 HW0 v3 October 2, 2018 1 CSE 252A Computer Vision I Fall 2018 - Assignment 0 1.0.1 Instructor: David Kriegman 1.0.2 Assignment Published On: Tuesday, October 2, 2018 1.0.3 Due On: Tuesday, October 9, 2018

More information

Numpy fast array interface

Numpy fast array interface NUMPY Numpy fast array interface Standard Python is not well suitable for numerical computations lists are very flexible but also slow to process in numerical computations Numpy adds a new array data type

More information

Lecture 15: High Dimensional Data Analysis, Numpy Overview

Lecture 15: High Dimensional Data Analysis, Numpy Overview Lecture 15: High Dimensional Data Analysis, Numpy Overview Chris Tralie, Duke University 3/3/2016 Announcements Mini Assignment 3 Out Tomorrow, due next Friday 3/11 11:55PM Rank Top 3 Final Project Choices

More information

ARTIFICIAL INTELLIGENCE AND PYTHON

ARTIFICIAL INTELLIGENCE AND PYTHON ARTIFICIAL INTELLIGENCE AND PYTHON DAY 1 STANLEY LIANG, LASSONDE SCHOOL OF ENGINEERING, YORK UNIVERSITY WHAT IS PYTHON An interpreted high-level programming language for general-purpose programming. Python

More information

DSC 201: Data Analysis & Visualization

DSC 201: Data Analysis & Visualization DSC 201: Data Analysis & Visualization Arrays and Series Dr. David Koop Exception Example def divide(mylist, x,y): newlist = [] try: z = x // y below, mid, above = \ mylist[:z], mylist[z], mylist[z+1:]

More information

Tentative NumPy Tutorial

Tentative NumPy Tutorial Page 1 of 30 Tentative NumPy Tutorial Please do not hesitate to click the edit button. You will need to create a User Account first. Contents 1. Prerequisites 2. The Basics 1. An example 2. Array Creation

More information

NumPy. Arno Proeme, ARCHER CSE Team Attributed to Jussi Enkovaara & Martti Louhivuori, CSC Helsinki

NumPy. Arno Proeme, ARCHER CSE Team Attributed to Jussi Enkovaara & Martti Louhivuori, CSC Helsinki NumPy Arno Proeme, ARCHER CSE Team aproeme@epcc.ed.ac.uk Attributed to Jussi Enkovaara & Martti Louhivuori, CSC Helsinki Reusing this material This work is licensed under a Creative Commons Attribution-

More information

Supervised Learning in Neural Networks (Part 2)

Supervised Learning in Neural Networks (Part 2) Supervised Learning in Neural Networks (Part 2) Multilayer neural networks (back-propagation training algorithm) The input signals are propagated in a forward direction on a layer-bylayer basis. Learning

More information

CSC 578 Neural Networks and Deep Learning

CSC 578 Neural Networks and Deep Learning CSC 578 Neural Networks and Deep Learning Fall 2018/19 7. Recurrent Neural Networks (Some figures adapted from NNDL book) 1 Recurrent Neural Networks 1. Recurrent Neural Networks (RNNs) 2. RNN Training

More information

An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type.

An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Data Structures Introduction An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Representation of a large number of homogeneous

More information

The NumPy Array: A Structure for Efficient Numerical Computation

The NumPy Array: A Structure for Efficient Numerical Computation The NumPy Array: A Structure for Efficient Numerical Computation Presented at the G-Node Autumn School on Advanced Scientific Programming in Python, held in Kiel, Germany Stéfan van der Walt UC Berkeley

More information

Keras: Handwritten Digit Recognition using MNIST Dataset

Keras: Handwritten Digit Recognition using MNIST Dataset Keras: Handwritten Digit Recognition using MNIST Dataset IIT PATNA February 9, 2017 1 / 24 OUTLINE 1 Introduction Keras: Deep Learning library for Theano and TensorFlow 2 Installing Keras Installation

More information

LECTURE NOTES Professor Anita Wasilewska NEURAL NETWORKS

LECTURE NOTES Professor Anita Wasilewska NEURAL NETWORKS LECTURE NOTES Professor Anita Wasilewska NEURAL NETWORKS Neural Networks Classifier Introduction INPUT: classification data, i.e. it contains an classification (class) attribute. WE also say that the class

More information

Natural Language Processing CS 6320 Lecture 6 Neural Language Models. Instructor: Sanda Harabagiu

Natural Language Processing CS 6320 Lecture 6 Neural Language Models. Instructor: Sanda Harabagiu Natural Language Processing CS 6320 Lecture 6 Neural Language Models Instructor: Sanda Harabagiu In this lecture We shall cover: Deep Neural Models for Natural Language Processing Introduce Feed Forward

More information

DSC 201: Data Analysis & Visualization

DSC 201: Data Analysis & Visualization DSC 201: Data Analysis & Visualization Classes & Arrays Dr. David Koop Sets Sets are like dictionaries but without any values: s = {'MA', 'RI', 'CT', 'NH'}; t = {'MA', 'NY', 'NH'} {} is an empty dictionary,

More information

MO101: Python for Engineering Vladimir Paun ENSTA ParisTech

MO101: Python for Engineering Vladimir Paun ENSTA ParisTech I MO101: Python for Engineering Vladimir Paun ENSTA ParisTech License CC BY-NC-SA 2.0 http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Introduction to Python Introduction About Python Python itself

More information

Autoencoder. By Prof. Seungchul Lee isystems Design Lab UNIST. Table of Contents

Autoencoder. By Prof. Seungchul Lee isystems Design Lab  UNIST. Table of Contents Autoencoder By Prof. Seungchul Lee isystems Design Lab http://isystems.unist.ac.kr/ UNIST Table of Contents I. 1. Unsupervised Learning II. 2. Autoencoders III. 3. Autoencoder with TensorFlow I. 3.1. Import

More information

NumPy User Guide. Release Written by the NumPy community

NumPy User Guide. Release Written by the NumPy community NumPy User Guide Release 1.11.0 Written by the NumPy community May 29, 2016 CONTENTS 1 Setting up 3 1.1 What is NumPy?............................................. 3 1.2 Installing NumPy.............................................

More information

Pandas and Friends. Austin Godber Mail: Source:

Pandas and Friends. Austin Godber Mail: Source: Austin Godber Mail: godber@uberhip.com Twitter: @godber Source: http://github.com/desertpy/presentations What does it do? Pandas is a Python data analysis tool built on top of NumPy that provides a suite

More information

Part VI. Scientific Computing in Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26,

Part VI. Scientific Computing in Python. Tobias Neckel: Scripting with Bash and Python Compact Max-Planck, February 16-26, Part VI Scientific Computing in Python Compact Course @ Max-Planck, February 16-26, 2015 81 More on Maths Module math Constants pi and e Functions that operate on int and float All return values float

More information

NumPy is suited to many applications Image processing Signal processing Linear algebra A plethora of others

NumPy is suited to many applications Image processing Signal processing Linear algebra A plethora of others Introduction to NumPy What is NumPy NumPy is a Python C extension library for array-oriented computing Efficient In-memory Contiguous (or Strided) Homogeneous (but types can be algebraic) NumPy is suited

More information

Python Pandas- II Dataframes and Other Operations

Python Pandas- II Dataframes and Other Operations Python Pandas- II Dataframes and Other Operations Based on CBSE Curriculum Class -11 By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region Neha Tyagi, KV 5 Jaipur II Shift Introduction In last chapter,

More information

An introduction to scientific programming with. Session 2: Numerical Python and plotting

An introduction to scientific programming with. Session 2: Numerical Python and plotting An introduction to scientific programming with Session 2: Numerical Python and plotting So far core Python language and libraries Extra features required: fast, multidimensional arrays plotting tools libraries

More information

COMP 551 Applied Machine Learning Lecture 14: Neural Networks

COMP 551 Applied Machine Learning Lecture 14: Neural Networks COMP 551 Applied Machine Learning Lecture 14: Neural Networks Instructor: (jpineau@cs.mcgill.ca) Class web page: www.cs.mcgill.ca/~jpineau/comp551 Unless otherwise noted, all material posted for this course

More information

NumPy and SciPy. Shawn T. Brown Director of Public Health Applications Pittsburgh Supercomputing Center Pittsburgh Supercomputing Center

NumPy and SciPy. Shawn T. Brown Director of Public Health Applications Pittsburgh Supercomputing Center Pittsburgh Supercomputing Center NumPy and SciPy Shawn T. Brown Director of Public Health Applications Pittsburgh Supercomputing Center 2012 Pittsburgh Supercomputing Center What are NumPy and SciPy NumPy and SciPy are open-source add-on

More information

Introduction to Artificial Neural Networks and Deep Learning

Introduction to Artificial Neural Networks and Deep Learning Introduction to Artificial Neural Networks and Deep Learning A Practical Guide with Applications in Python Sebastian Raschka This book is for sale at http://leanpub.com/ann-and-deeplearning This version

More information

Autoencoder. 1. Unsupervised Learning. By Prof. Seungchul Lee Industrial AI Lab POSTECH.

Autoencoder. 1. Unsupervised Learning. By Prof. Seungchul Lee Industrial AI Lab  POSTECH. Autoencoder By Prof. Seungchul Lee Industrial AI Lab http://isystems.unist.ac.kr/ POSTECH Table of Contents I. 1. Unsupervised Learning II. 2. Autoencoders III. 3. Autoencoder with TensorFlow I. 3.1. Import

More information

Lecture 2 Notes. Outline. Neural Networks. The Big Idea. Architecture. Instructors: Parth Shah, Riju Pahwa

Lecture 2 Notes. Outline. Neural Networks. The Big Idea. Architecture. Instructors: Parth Shah, Riju Pahwa Instructors: Parth Shah, Riju Pahwa Lecture 2 Notes Outline 1. Neural Networks The Big Idea Architecture SGD and Backpropagation 2. Convolutional Neural Networks Intuition Architecture 3. Recurrent Neural

More information

Autoencoder. 1. Unsupervised Learning. By Prof. Seungchul Lee Industrial AI Lab POSTECH.

Autoencoder. 1. Unsupervised Learning. By Prof. Seungchul Lee Industrial AI Lab  POSTECH. Autoencoder By Prof. Seungchul Lee Industrial AI Lab http://isystems.unist.ac.kr/ POSTECH Table of Contents I. 1. Unsupervised Learning II. 2. Autoencoders III. 3. Autoencoder with TensorFlow I. 3.1. Import

More information

Handling arrays in Python (numpy)

Handling arrays in Python (numpy) Handling arrays in Python (numpy) Thanks to all contributors: Alison Pamment, Sam Pepler, Ag Stephens, Stephen Pascoe, Anabelle Guillory, Graham Parton, Esther Conway, Wendy Garland, Alan Iwi and Matt

More information

Neural Networks (pp )

Neural Networks (pp ) Notation: Means pencil-and-paper QUIZ Means coding QUIZ Neural Networks (pp. 106-121) The first artificial neural network (ANN) was the (single-layer) perceptron, a simplified model of a biological neuron.

More information

Deep Nets with. Keras

Deep Nets with. Keras docs https://keras.io Deep Nets with Keras κέρας http://vem.quantumunlimited.org/the-gates-of-horn/ Professor Marie Roch These slides only cover enough to get started with feed-forward networks and do

More information

Neural Networks. CE-725: Statistical Pattern Recognition Sharif University of Technology Spring Soleymani

Neural Networks. CE-725: Statistical Pattern Recognition Sharif University of Technology Spring Soleymani Neural Networks CE-725: Statistical Pattern Recognition Sharif University of Technology Spring 2013 Soleymani Outline Biological and artificial neural networks Feed-forward neural networks Single layer

More information

COMP1730/COMP6730 Programming for Scientists. Sequence types, part 2

COMP1730/COMP6730 Programming for Scientists. Sequence types, part 2 COMP1730/COMP6730 Programming for Scientists Sequence types, part 2 Lecture outline * Lists * Mutable objects & references Sequence data types (recap) * A sequence contains n 0 values (its length), each

More information

Table of Contents. Preface... xxi

Table of Contents. Preface... xxi Table of Contents Preface... xxi Chapter 1: Introduction to Python... 1 Python... 2 Features of Python... 3 Execution of a Python Program... 7 Viewing the Byte Code... 9 Flavors of Python... 10 Python

More information

Index. Umberto Michelucci 2018 U. Michelucci, Applied Deep Learning,

Index. Umberto Michelucci 2018 U. Michelucci, Applied Deep Learning, A Acquisition function, 298, 301 Adam optimizer, 175 178 Anaconda navigator conda command, 3 Create button, 5 download and install, 1 installing packages, 8 Jupyter Notebook, 11 13 left navigation pane,

More information

DSC 201: Data Analysis & Visualization

DSC 201: Data Analysis & Visualization DSC 201: Data Analysis & Visualization Data Frames Dr. David Koop 2D Indexing [W. McKinney, Python for Data Analysis] 2 Boolean Indexing names == 'Bob' gives back booleans that represent the elementwise

More information

How to declare an array in C?

How to declare an array in C? Introduction An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Representation of a large number of homogeneous values.

More information

NumPy User Guide. Release dev7335. Written by the NumPy community

NumPy User Guide. Release dev7335. Written by the NumPy community NumPy User Guide Release 1.4.0.dev7335 Written by the NumPy community August 28, 2009 CONTENTS 1 Building and installing NumPy 3 1.1 Binary installers............................................. 3 1.2

More information

NumPy User Guide. Release dev7072. Written by the NumPy community

NumPy User Guide. Release dev7072. Written by the NumPy community NumPy User Guide Release 1.4.0.dev7072 Written by the NumPy community June 24, 2009 CONTENTS 1 Building and installing NumPy 3 1.1 Binary installers............................................. 3 1.2

More information

Logistic Regression with a Neural Network mindset

Logistic Regression with a Neural Network mindset Logistic Regression with a Neural Network mindset Welcome to your first (required) programming assignment! You will build a logistic regression classifier to recognize cats. This assignment will step you

More information

NumPy User Guide. Release Written by the NumPy community

NumPy User Guide. Release Written by the NumPy community NumPy User Guide Release 1.16.1 Written by the NumPy community January 31, 2019 CONTENTS 1 Setting up 3 2 Quickstart tutorial 5 3 NumPy basics 27 4 Miscellaneous 77 5 NumPy for Matlab users 81 6 Building

More information

CS6220: DATA MINING TECHNIQUES

CS6220: DATA MINING TECHNIQUES CS6220: DATA MINING TECHNIQUES Image Data: Classification via Neural Networks Instructor: Yizhou Sun yzsun@ccs.neu.edu November 19, 2015 Methods to Learn Classification Clustering Frequent Pattern Mining

More information

NumPy User Guide. Release Written by the NumPy community

NumPy User Guide. Release Written by the NumPy community NumPy User Guide Release 1.14.0 Written by the NumPy community January 08, 2018 CONTENTS 1 Setting up 3 2 Quickstart tutorial 5 3 NumPy basics 29 4 Miscellaneous 73 5 NumPy for Matlab users 79 6 Building

More information

Building your Deep Neural Network: Step by Step

Building your Deep Neural Network: Step by Step Building your Deep Neural Network: Step by Step Welcome to your week 4 assignment (part 1 of 2)! You have previously trained a 2-layer Neural Network (with a single hidden layer). This week, you will build

More information

Deep Learning for Visual Computing Prof. Debdoot Sheet Department of Electrical Engineering Indian Institute of Technology, Kharagpur

Deep Learning for Visual Computing Prof. Debdoot Sheet Department of Electrical Engineering Indian Institute of Technology, Kharagpur Deep Learning for Visual Computing Prof. Debdoot Sheet Department of Electrical Engineering Indian Institute of Technology, Kharagpur Lecture - 05 Classification with Perceptron Model So, welcome to today

More information

CS224n: Natural Language Processing with Deep Learning 1

CS224n: Natural Language Processing with Deep Learning 1 CS224n: Natural Language Processing with Deep Learning 1 Lecture Notes: TensorFlow 2 Winter 2017 1 Course Instructors: Christopher Manning, Richard Socher 2 Authors: Zhedi Liu, Jon Gauthier, Bharath Ramsundar,

More information

DSC 201: Data Analysis & Visualization

DSC 201: Data Analysis & Visualization DSC 201: Data Analysis & Visualization Data Frames Dr. David Koop pandas Contains high-level data structures and manipulation tools designed to make data analysis fast and easy in Python Built on top of

More information

Multilayer Feed-forward networks

Multilayer Feed-forward networks Multi Feed-forward networks 1. Computational models of McCulloch and Pitts proposed a binary threshold unit as a computational model for artificial neuron. This first type of neuron has been generalized

More information

Intelligente Datenanalyse Intelligent Data Analysis

Intelligente Datenanalyse Intelligent Data Analysis Universität Potsdam Institut für Informatik Lehrstuhl Maschinelles Lernen Intelligent Data Analysis Tobias Scheffer, Gerrit Gruben, Nuno Marquez Plan for this lecture Introduction to Python Main goal is

More information

Artificial Neural Networks Lecture Notes Part 5. Stephen Lucci, PhD. Part 5

Artificial Neural Networks Lecture Notes Part 5. Stephen Lucci, PhD. Part 5 Artificial Neural Networks Lecture Notes Part 5 About this file: If you have trouble reading the contents of this file, or in case of transcription errors, email gi0062@bcmail.brooklyn.cuny.edu Acknowledgments:

More information

Machine Learning 13. week

Machine Learning 13. week Machine Learning 13. week Deep Learning Convolutional Neural Network Recurrent Neural Network 1 Why Deep Learning is so Popular? 1. Increase in the amount of data Thanks to the Internet, huge amount of

More information

Introducing Python Pandas

Introducing Python Pandas Introducing Python Pandas Based on CBSE Curriculum Class -11 By- Neha Tyagi PGT CS KV 5 Jaipur II Shift Jaipur Region Neha Tyagi, KV 5 Jaipur II Shift Introduction Pandas or Python Pandas is a library

More information

CS230: Deep Learning Winter Quarter 2018 Stanford University

CS230: Deep Learning Winter Quarter 2018 Stanford University : Deep Learning Winter Quarter 08 Stanford University Midterm Examination 80 minutes Problem Full Points Your Score Multiple Choice 7 Short Answers 3 Coding 7 4 Backpropagation 5 Universal Approximation

More information

Convolutional Neural Networks (CNN)

Convolutional Neural Networks (CNN) Convolutional Neural Networks (CNN) By Prof. Seungchul Lee Industrial AI Lab http://isystems.unist.ac.kr/ POSTECH Table of Contents I. 1. Convolution on Image I. 1.1. Convolution in 1D II. 1.2. Convolution

More information

Computational Physics

Computational Physics Computational Physics Objects : Lists & Arrays Prof. Paul Eugenio Department of Physics Florida State University Jan 24, 2019 http://hadron.physics.fsu.edu/~eugenio/comphy/ Announcements Read chapter 3

More information

Numerical Calculations

Numerical Calculations Fundamentals of Programming (Python) Numerical Calculations Sina Sajadmanesh Sharif University of Technology Some slides have been adapted from Scipy Lecture Notes at http://www.scipy-lectures.org/ Outline

More information

Introduction to Python and NumPy I

Introduction to Python and NumPy I Introduction to Python and NumPy I This tutorial is continued in part two: Introduction to Python and NumPy II Table of contents Overview Launching Canopy Getting started in Python Getting help Python

More information

Planar data classification with one hidden layer

Planar data classification with one hidden layer Planar data classification with one hidden layer Welcome to your week 3 programming assignment. It's time to build your first neural network, which will have a hidden layer. You will see a big difference

More information

Classification Lecture Notes cse352. Neural Networks. Professor Anita Wasilewska

Classification Lecture Notes cse352. Neural Networks. Professor Anita Wasilewska Classification Lecture Notes cse352 Neural Networks Professor Anita Wasilewska Neural Networks Classification Introduction INPUT: classification data, i.e. it contains an classification (class) attribute

More information

CME 193: Introduction to Scientific Python Lecture 5: Object Oriented Programming

CME 193: Introduction to Scientific Python Lecture 5: Object Oriented Programming CME 193: Introduction to Scientific Python Lecture 5: Object Oriented Programming Nolan Skochdopole stanford.edu/class/cme193 5: Object Oriented Programming 5-1 Contents Classes Numpy Exercises 5: Object

More information

cosmos_python_ Python as calculator May 31, 2018

cosmos_python_ Python as calculator May 31, 2018 cosmos_python_2018 May 31, 2018 1 Python as calculator Note: To convert ipynb to pdf file, use command: ipython nbconvert cosmos_python_2015.ipynb --to latex --post pdf In [3]: 1 + 3 Out[3]: 4 In [4]:

More information

Introduction to Machine Learning. Useful tools: Python, NumPy, scikit-learn

Introduction to Machine Learning. Useful tools: Python, NumPy, scikit-learn Introduction to Machine Learning Useful tools: Python, NumPy, scikit-learn Antonio Sutera and Jean-Michel Begon September 29, 2016 2 / 37 How to install Python? Download and use the Anaconda python distribution

More information

IAP Python - Lecture 4

IAP Python - Lecture 4 IAP Python - Lecture 4 Andrew Farrell MIT SIPB January 13, 2011 NumPy, SciPy, and matplotlib are a collection of modules that together are trying to create the functionality of MATLAB in Python. Andrew

More information

User-Defined Function

User-Defined Function ENGR 102-213 (Socolofsky) Week 11 Python scripts In the lecture this week, we are continuing to learn powerful things that can be done with userdefined functions. In several of the examples, we consider

More information

SciPy. scipy [www.scipy.org and links on course web page] scipy arrays

SciPy. scipy [www.scipy.org and links on course web page] scipy arrays SciPy scipy [www.scipy.org and links on course web page] - scipy is a collection of many useful numerical algorithms (numpy is the array core) - Python wrappers around compiled libraries and subroutines

More information