Skip to content

Instantly share code, notes, and snippets.

@c0rp-aubakirov
Created March 31, 2019 12:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c0rp-aubakirov/2ceae98e496457e21e8cab39715d60a9 to your computer and use it in GitHub Desktop.
Save c0rp-aubakirov/2ceae98e496457e21e8cab39715d60a9 to your computer and use it in GitHub Desktop.
Course preparation guide
---
:: folders ::
(a) create the "_AI_RL" folder for the course
(b) create the "_AI_RL\__vEnv_py3-x-y" folder for the python virtual environment
where x and y are the Python3 version numbers
---
Hands-On software:
- python3
- numpy, matplotlib
- OpenAi-gym
- TensorFlow
Attention:
- be aware that you must install a python version that is compatible with the TensorFlow version; constraints are described in the TensorFlow web page
- for example:
python 3.6.8 and tensorflow 1.5
>> is the combination that works for OSX El Captain, version 10.11.6 <<
- if you do not have any constraints maybe you can install the last version of each
Suggestion:
- install everything in a virtual-environment
- I used "venv" instead of "virtualEnv" tool because of some rendering limitation of "virtualEnv"
- I did not found limitations in the "venv" tool and it comes "bundled" with all python3 versions
---
As an example my installation process was as follows:
:: recall that I had to install python3.6.8
- you may install any later version
- as long as it is compatible with your TensorFlow version
:: venv is already shipped together with python3 ::
:: To create a venv with python3 (in my case python3.6.8) run:
$ python3.6 -m venv ./__vEnv_py3-6-8
:: Activate the venv:
$ source ./__vEnv_py3-6-8/bin/activate
$ source ./bin/activate
:: test the venv ::
$ python
>>> "Python 3.6.8"
>>> exit()
:: Upgrade pip ::
$ python -m pip install --upgrade pip
# pip installation was giving an error related with SSL
# solved the problem after executing:
$ curl https://bootstrap.pypa.io/get-pip.py | python
$ python -m pip install --upgrade pip
:: get the list of installed packages ::
$ pip list
:: Install numpy, matplotlib ::
(make sure that you are running under the venv scope)
(i.e., that you have already executed "$ source ./__vEnv_py3-6-8/bin/activate")
$ pip install numpy matplotlib
$ pip install gym
:: Install TensorFlow ::
:: I had problems due to my "old" version of operating system
:: so I had to install tensorflow r1.5
$ pip install --upgrade pip
$ pip install --upgrade tensorflow==1.5
:: Test_01 - TensorFlow ::
$ python
>>> import tensorflow as tf
>>> hello = tf.constant( "Hello TensorFlow!" )
>>> sess = tf.Session()
>>> result = sess.run( hello )
>>> print( result )
b'Hello TensorFlow!'
>>> exit()
:: Test_01 - matplotlib.pyplot, numpy ::
- edit a file with the following code and execute it (within venv):
# import library
import matplotlib.pyplot as plt
import numpy as np
# build data
x = np.linspace( 0, 10, 100 )
# plot data
plt.plot( x, x, label='linear' )
# add legend
plt.legend()
# show plot
plt.show()
# :: test_02 - - matplotlib.pyplot, numpy ::
- edit a file with the following code and execute it (within venv):
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot([1, 2, 3, 4], [10, 20, 25, 30], color='lightblue', linewidth=3)
ax.scatter([0.3, 3.8, 1.2, 2.5], [11, 25, 9, 26], color='darkgreen', marker='^')
ax.set_xlim(0.5, 4.5)
plt.show()
:: Deactivate the venv (in the command-line):
$ deactivate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment