• Nie Znaleziono Wyników

Cutting-Edge Python Computational Tools

N/A
N/A
Protected

Academic year: 2021

Share "Cutting-Edge Python Computational Tools"

Copied!
22
0
0

Pełen tekst

(1)

Cutting-Edge Python Computational Tools for AI, CI, KE and Data Mining

AGH University of Science and Technology

Krakow, Poland

Adrian Horzyk

horzyk@agh.edu.pl

ARTIFICIAL AND COMPUTATIONAL INTELLIGENCE

AND KNOWLEDGE ENGINEERING

(2)

Scope

 Python – a modern language often used for AI, CI, KE, and DM computing

 Jupyter Notebook – a modern and

intuitive programming environment with linked libraries (like Tensorflow, Keras) that allow to effectively process deep learning algorithms and show results quickly.

 Tensorflow and Keras libraries produced

by leading IT companies, like Google.

(3)

Jupyter Notebook The Jupyter Notebook:

• is an open-source web application that allows you to create and share

documents that contain live code, equations, visualizations and narrative text;

• includes data cleaning and transformation, numerical simulation, statistical modeling, data visualization, machine learning, and much more.

We will use it to demonstrate various algorithms, so you are asked to install it.

Jupyter in your browser Install a Jupyter Notebook

(4)

Jupyter Notebook & Anaconda

Install Jupyter using Anaconda with built in Python 3.7+

• It includes many other commonly used packages for scientific computing, data science, machine learning ,and computational intelligence libraries.

• It manages libraries, dependencies, and environments with Conda.

• It allows developing and training various machine learning and deep learning models with scikit-learn, TensorFlow, and Theano etc.

• It supplies us with data analysis including scalability and performance with Dask, NumPy, pandas, and Numba.

• It quickly visualizes results with Matplotlib, Bokeh, Datashader, and Holoviews.

And run it at the Terminal

(Mac/Linux) or Command

Prompt (Windows):

(5)

Anaconda Cloud

(6)

Jupyter Notebook Dashboard Running a Jupyter Notebook

in your browser:

• When the Jupyter Notebook opens in your browser,

you will see the Notebook Dashboard, which will show you a list of

the notebooks, files, and

subdirectories in the directory where the notebook server was started by the command line

„jupyter notebook”.

• Most of the time, you will wish to start a notebook server in the highest level directory containing notebooks.

Often this will be your home

directory.

(7)

Jupyter Notebook & PyCharm

It is recommended to install PyCharm for Anaconda:

(8)

Jupyter Notebook

PyCharm is a python IDE for Professional Developers

• It includes scientific mode to interactively analyze your data.

(9)

Starting a new Python notebook

Start a new Python notebook:

• Clicking New  Python 3

• And a new Python project in the Jupyter Notebook will be started:

(10)

Efficiency of Vectorization

When dealing with big data collections and big data vectors, we should use vectorization to proceed computations faster:

Conclusion:

Whenever possible, avoid explicit for-loops and use vectorization:

np.dot(A,v), np.dot(x,w), np.log(v), np.abs(v),

np.zeros(v), np.sum(v) etc.

(11)

Computing Sigmoid Function

We use numpy vectorization to compute sigmoid(x) and sigmoid_derivative

for any input vector x:

(12)

Normalization for Efficiency

We use normalization to achieve a better performance because gradient descent

converges faster after normalization:

(13)

Broadcasting in numpy

Broadcasting is very useful for performing mathematical operations between

arrays of different shapes.

(14)

Reshaping Image Matrices

When working with images in deep learning, we typically reshape them into vector

representation using np.reshape() :

(15)

Shape and Reshape Vectors and Matrices

We commonly use the numpy functions np.shape() and np.reshape() in deep learning:

• X.shape is used to get the shape (dimension) of a vector or a matrix X.

• X.reshape(...) is used to reshape a vector or a matrix X into some other dimension(s).

(16)

Vectorization of Dot Product

In deep learning, you deal with very large datasets. Non-computationally-optimal functions become a huge bottleneck in your algorithms and can result in models that take ages to run. To make sure that your code is computationally efficient, you should use vectorization. Compare the following codes:

(17)

Vectorization of Outer Product

In deep learning, you deal with very large datasets. Non-computationally-optimal functions become a huge bottleneck in your algorithms and can result in models that take ages to run. To make sure that your code is computationally efficient, you should use vectorization. Compare the following codes:

(18)

Vectorization of Element-Wise Multiplication

In deep learning, you deal with very large datasets. Non-computationally-optimal functions become a huge bottleneck in your algorithms and can result in models that take ages to run. To make sure that your code is computationally efficient, you should use vectorization. Compare the following codes:

(19)

Vectorization of General Dot Product

In deep learning, you deal with very large datasets. Non-computationally-optimal functions become a huge bottleneck in your algorithms and can result in models that take ages to run. To make sure that your code is computationally efficient, you should use vectorization. Compare the following codes:

(20)

Loss Functions

The loss functions are used to evaluate the performance of your models. The bigger your

loss is, the more different your predictions (𝑦̂) are from the true values (𝑦). In deep learning,

we use optimization algorithms like Gradient Descent to train models and minimize the cost.

(21)

Let’s start with powerful computations!

Questions?

Remarks?

Suggestions?

Wishes?

(22)

Bibliography and Literature

1. Nikola K. Kasabov, Time-Space, Spiking Neural Networks and Brain-Inspired Artificial Intelligence, In Springer Series on Bio- and Neurosystems, Vol 7., Springer, 2019.

2. Ian Goodfellow, Yoshua Bengio, Aaron Courville, Deep Learning, MIT Press, 2016, ISBN 978- 1-59327-741-3 or PWN 2018.

3. Holk Cruse,Neural Networks as Cybernetic Systems, 2nd and revised edition 4. R. Rojas,Neural Networks, Springer-Verlag, Berlin, 1996.

5. Convolutional Neural Network(Stanford)

6. Visualizing and Understanding Convolutional Networks, Zeiler, Fergus, ECCV 2014 7. IBM: https://www.ibm.com/developerworks/library/ba-data-becomes-knowledge-

1/index.html

8. NVIDIA: https://developer.nvidia.com/discover/convolutional-neural-network 9. JUPYTER: https://jupyter.org/

University of Science and Technology in Krakow, Poland Adrian Horzyk horzyk@agh.edu.pl

Google: Horzyk

Cytaty

Powiązane dokumenty

„Iinną częścią religii praw d ziw ej jtest nasza pow inność w obec człow ieka.. A ugustyna, zw ykło

With the welfare of the economy in terms of price stability and employment being emphasised on, the economic authorities within the Euro Zone are able to apply basic

An Open Coloring Axiom type principle is formulated for uncountable cardinals and is shown to be a consequence of the Proper Forcing Axiom.. Several appli- cations

For the problems being considered, issues related to the computational complexity of the problem and known optimal for all instances of the problem algorithms will

A group of 30 children are surveyed to find out which of the three sports cricket (C), basketball (B) or volleyball (V) they play.. The results are

Non-computationally-optimal functions become a huge bottleneck in your algorithms and can result in models that take ages to run. To make sure that your code is

Postawił go na silnej podstawie metodologicznej, żądając najbar­ dziej stanowczo oparcia systematyki na kryterjach natury praw­ niczej. Zbyt głęboko jednak usiłował sięgnąć,