Introduction to Robot Vision through Python and Keras
Introduction to Python and Keras Part II Outline Anaconda Installation Create conda Environment Install Necessary Packages Pycharm Installation Import and Run Code in Pycharm Jupyter Notebooks Keras MNIST
Anaconda - Installation Anaconda can help you install and manage all the libraries you are going to need for your machine learning/computer vision tasks. The installation instructions for the following platforms are linked below: Windows MacOS Linux - https://docs.anaconda.com/anaconda/install/windows/ https://docs.anaconda.com/anaconda/install/mac-os/ https://docs.anaconda.com/anaconda/install/linux/
The instructions are very clear and helpful. We recommend following them precisely. At the end of these instructions, there will be a link to install Pycharm. Save this link. Well use it in a few slides. (We recommend that you use Anaconda 3 with Python 3.6 on a Unix based system (a popular Linux distro like Ubuntu or Mac) so that we can help you with debugging errors at a later stage.) Anaconda Advanced Users Only Be Careful with Replacing Existing Stuff If you have existing projects that strictly depend on a certain version of
Python, unchecking options like the one shown may be needed. Same applies for command-line installation i.e. select no (type n). NOTE: If you do not understand this page, simply follow the Anaconda instructions from the previous page. Anaconda - Environments Anaconda virtual environments are workspaces isolated from the rest of your machine. They keep dependencies required by different projects separate Create an environment:
Mac/Linux (in terminal/shell): Create: conda create -n yourenvname python=3.6 anaconda Activate: source activate yourenvname or conda activate yourenvname Deactivate: deactivate yourenvname Windows (in Anaconda Prompt): Create: conda create -n yourenvname python=3.6 anaconda Activate: activate yourenvname Deactivate: deactivate yourenvname Anaconda - Environments By including the command anaconda at the end when creating an environment, all standard packages will be installed.
Once your environment is activated: List all installed packages with conda list: This is very useful to check if certain packages are currently installed Install new packages (specifically the ones well need): Tensorflow: conda install tensorflow (dont have GPU) or conda install tensorflow-gpu (you have GPU) Keras: conda install -c conda-forge keras Note: Google conda install your_package before installing anything Problem? Visit the docs at: https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html pip vs. Anaconda
If any library such as numpy, scipy, matplotlib, etc. cannot be installed using conda install -n yourenvname [package], it can probably be found under the pip package. Install pip using the above command and then install the desired library using pip install [package]. Libraries A-X CONDA Libraries D-Z PIP Library PyCharm
PyCharm is a powerful Integrated Development Environment (IDE) for Python projects. Use the PyCharm installation link obtained at the final stage of your Anaconda installation (it can be found at https://www.jetbrains.com/pycharm/promo/anaconda/ ). Use university email to obtain the Professional Edition for free. PyCharm can help with auto-completing functions. VERY useful for new users. NOTE: You can create conda environments and install packages using Pycharm. However, we highly recommend using the methods
PyCharm New Project Interpreter 1) Name your project 2) Click Existing interpreter 3) Select menu button PyCharm New Project Interpreter 1) Select Conda Environment from left hand menu bar 2) Click Make available to all
projects 3) Select menu button PyCharm New Project Interpreter Navigate to /anaconda3/envs/YourEnv/bin/ python and select the python, python3, python.exe, or something similar The above path may not be the exact same as on your machine. Navigate around until you find a similar directory, then look for the sub-directory listed in
the above path For additional help, the following tutorial is https://bit.ly/2X4wgFi very helpful PyCharm New Project 1) Right-click on project name in left hand menu bar 2) Select New 3) Select Python File NOTE: Right after you open a new project, PyCharm might not run code for a short time. This is
because it is updating system info. PyCharm New Project 1) To run your code for the first time, right-click in the editor window and scroll down to Run MyCode Jupyter Notebooks Allows you to edit and run your notebooks via a (local) web browser Run one cell at a time. Helps to troubleshoot or experiment
Comes installed with Anaconda To run a Jupyter Notebook, open Terminal/Shell/CMD and type jupyter notebook Keras Among a bunch of deep learning frameworks, Keras is probably the easiest to begin with: TensorFlow, Keras, PyTorch, Chainer, Caffe, Theano, etc. Keras is: A high-level neural network API with support for both CPU and GPU. Modular - Building models can be as simple as stacking layers.
Useful for fast prototyping as we can ignore implementation details of backpropagation, Open source - Large community support. Comprehensive - Contains implementations of popular networks, datasets, etc. Has luxury of using any backend from TensorFlow, Theano, or CNTK without change in code. Pipeline to Implement an NN-based Model in Keras 1. Specify the input size and output size. 2. Design and define the NN architecture.
3. Select the optimizer that performs gradient descent. 4. Select the loss function and train the network for an objective. 5. Select appropriate evaluation metrics for the problem youre working on. Prepare input and specify size (Images, videos, text, audio, etc.)
Define the NN model (Sequential or Functional style) (MLP, CNN, RNN, etc.) Optimizer s
Loss function (SGD, RMSprop, Adam, etc.) (MSE, Cross entropy, Hinge, etc.) Train and
evaluate the model Keras Models Sequential: Linear stack of layers. Useful for building: Simple classification networks. Encoder-Decoder networks. Basically any single-flow network. Under Keras as Sequential() class.
Functional: Multi-input, multi-output models. Supports, forking/branching of models. Supports intermediate merging of models. Under Keras as Model() class. Sequential Model Code
1. Import Sequential class from keras.models. 2. Stack layers in a sequential object using .add() method. a. Only the first layer needs to know the expected input dimensions as next layers can infer shape from the previous layers. from keras.models import Sequential from keras.layers import Dense, Activation model = Sequential() # Dense is Keras lingo for a fully connected
layer model.add(Dense(units=64, input_dim=100)) model.add(Activation(relu)) model.add(Dense(units=10)) model.add(Activation(Softmax)) 3. Configure the learning process i.e. loss functions, optimizers, etc. using model.compile(loss=categorical_crossentropy the .compile() method. , optimizer=sgd,
4. Train the model using .fit() method metrics=[accuracy]) on training set tensors (can be np arrays). model.fit(X_train, Y_train, epochs=5, batch_size=32) Functional Model Code 1. Import Model class from keras.models. 2. Each layer has to explicitly return a tensor.
3. Manually pass the returned tensor to any compatible layer. a. Flexibility at the cost of a bit of code complexity. 4. Explicitly mention model inputs and outputs. 5. .compile() and .fit() same as a Sequential model. from keras.models import Model
from keras.layers import Input, Dense inputs = Input(shape=(784,)) x = Dense(64, activation=relu)(inputs) x = Dense(64, activation=relu)(x) predictions = Dense(10, activation=softmax) (x) model = Model(inputs=inputs, outputs=predictions) model.compile(loss=categorical_crossentropy , optimizer=rmsprop, metrics=[accuracy])
model.fit(X_train, Y_train, epochs=5, batch_size=32) MNIST - Imports MNIST Hyperparameters & Load Data MNIST Visualize Data MNIST Format Data MNIST Format Data
MNIST Define Sequential Convolutional Model MNIST Compile Model: Loss, Optimizer, Metrics MNIST Train & Test Model MNIST Inspect Output General Tips
1. Build a model step-by-step: move from simple to complicated models. 2. Train step-by-step: move from simple training (SGD) to using tricks. 3. Sanity check on noise, then overfit on a subset, then train on entire set. 4. Save and visualize all you can - models, predictions, data, tensor shapes, etc. 5. Refer documentation for default settings and whether they make sense for your problem (e.g. weight initialization, activation, learning rate, etc.). Afterword
The MNIST code above was implemented in a Jupyter Notebook and has been shared on Google CoLab at: https://colab.research.google.com/drive/16PbFjJFwKyuOBSDQZzsy4qZKJVEsDCRe For a complete (not in cells) version of the code, please visit: https://keras.io/examples/mnist_cnn/ Once you have completed this example, we recommend that you try implementing the following, slightly more advanced experiment: https://keras.io/examples/cifar10_cnn/
4 Elements Of A Map. Title. Scale. Compass. Legend. Many maps will have other parts to them, but all maps need these to understand the map's purpose. ... At the end of this presentation, you will fill in a blank...
(Paragrah 80) Some countries and regions began holding sessions and meetings as early as 2006, but formal recognition by the IGF Secretariat grew from then to 2009, when many countries were begining to formalize national and regional level initiatives.
WOW Welcoming our Wolves. On the Agenda for August 14th. Get schedule and pertinent information . Take a guided school tour. Participate in a showcase that highlights our school activities, clubs, sports, and academic programs
Building Distribution layer: The Building Distribution layer aggregates the wiring closets and uses switches to segment workgroups and isolate network problems. Building Core layer: The Building Core layer (also known as the Campus Backbone submodule) is a high-speed backbone and...
(Article 31.d, 42) To be implemented by Financial Services Authority and used to encourage: environmental conscious financing. green investment. Green islamic bond. 4. Emission/waste permit trading system (Article 31.e, 43, 44) To be implemented by GoI in at the latest...
Take SAT and/or ACT (SAT II if applicable) Create Common Application account (if applicable) Work on resume, essays. Begin asking teachers for Letters of Recommendation (if needed for applications or scholarships) Make note of SAT, ACT, SAT II Registration Deadlines...
Grants and Contracts in $1000 Publications and Presentations Graduate Student Enrollment Graduate Degree Granted Salary Survey 2004 Mechanical Engineers Application Process Graduate School (Check application for completeness) MAE Department (Register) MAE Faculty for Evaluation (Two to Three weeks) MAE Graduate...
Ready to download the document? Go ahead and hit continue!