This page is located in archive.

Intro to Numpy and Pytorch


You will be using python in this subject, as well as in many of your subjects throughout the Bachelors and Masters course. Python is extremely flexible and powerful, mostly due to the ease of use and the vast amount of available libraries for almost anything. We will be using python 3 (do not use python 2). Any version above 3.6 should be fine. Q: Isn't python slow? Yes, python is an interpreted language so it is slow. When performing computation / optimization python is used by calling very fast subroutines that are written in C/Fortran. Usually, over 95% of the computational time taken is spent in some low level library. This means that the python overhead is negligible. Python is unsuitable for applications such search in large graphs, high-end games, applications which are time-critical.

Python envs (optional)

Your linux distribution (ubuntu for example) already comes with some version of python 3 installed. This is the system interpreter. You can tell that you are installing onto your system interpreter if you need 'sudo' to perform a pip install command for example. Another solution would be to work with python environment. This can be done using an environment manager such as virtualenv and conda. This allows you to have multiple python environments on a single machine, each with different versions of packages etc. This guarantees that you don't have any conflicts between projects. Some more avid python users can exhibit a *mild* to severe reaction if you tell them that you install packages to your system interpreter.

Python workflow

Python scripts can be written in a simple “.py” file and run in the command terminal using “python myfile.py”. We do however advise the use of an IDE for development. A good choice is Pycharm (community version is okay, Czech Technical University provides the license for the Professional version, which ease working on the server later on). It provides autocompletion, debugging, syntax checking and many useful other tools.

Python basics

For those who want to refresh python or are just starting with it, we prepare quick refresher.

Numpy and Pytorch

Python, Numpy and Pytorch will be used for VIR labs and assignments. On the first lab, we will go through basic functionality of both packages. We will use lab1.zip for easier understanding. To download Jupyter notebook run the following:

pip install notebook

courses/b3b33urob/tutorials/lab_01.txt · Last modified: 2022/09/26 14:03 by cechjos3