mirror of
https://github.com/tiyn/wiki.git
synced 2025-11-08 06:01:15 +01:00
Compare commits
2 Commits
0999571c2c
...
74352a8ea9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74352a8ea9 | ||
|
|
d2897b2acd |
@@ -6,7 +6,10 @@ language.
|
|||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
You can install python using various ways.
|
You can install python using various ways.
|
||||||
With `pyenv` you can switch between different versions.
|
|
||||||
|
### pyenv Installation
|
||||||
|
|
||||||
|
With [pyenv](https://github.com/pyenv/pyenv) you can easily switch between different versions.
|
||||||
Install `pyenv` and `pyenv-virtualenv` and proceed with adding
|
Install `pyenv` and `pyenv-virtualenv` and proceed with adding
|
||||||
|
|
||||||
```txt
|
```txt
|
||||||
@@ -73,6 +76,43 @@ python3.9 --version
|
|||||||
To automatically create a `requirements.txt` of your current project, navigate
|
To automatically create a `requirements.txt` of your current project, navigate
|
||||||
to it and run `pipreqs` (install it if not already done).
|
to it and run `pipreqs` (install it if not already done).
|
||||||
|
|
||||||
|
### Using Virtual Environments
|
||||||
|
|
||||||
|
[venv](https://docs.python.org/3/library/venv.html) can be used to create a virtual environment.
|
||||||
|
|
||||||
|
```
|
||||||
|
python -m venv <project-path>
|
||||||
|
```
|
||||||
|
|
||||||
|
When inside the project folder the virtual environment can then be acivated by running the
|
||||||
|
following command.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
source ./bin/activate
|
||||||
|
```
|
||||||
|
|
||||||
|
And it can be disabled by running the following.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
deactivate
|
||||||
|
```
|
||||||
|
|
||||||
|
If pyenv is installed as described in [the setup section](#pyenv-installation) pyenv can be used to
|
||||||
|
manage virtual environments.
|
||||||
|
However pyenv won't create environment directories like venv does.
|
||||||
|
To fix this the following command can be used to simply link them both as described
|
||||||
|
[on StackOverflow by Jakob Guldberg Aaes](https://stackoverflow.com/questions/30407446/pyenv-choose-virtualenv-directory).
|
||||||
|
For this to work a virtual environment already has to be set up using venv as described before.
|
||||||
|
`<local-venv>` is the full path of the local virtual environment just created and `<venv-name>` the
|
||||||
|
name the venv should have in pyenv.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ln -s <local-venv> ~/.pyenv/versions/<venv-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
Using this setup the python version will automatically change when navigating into the project
|
||||||
|
directory.
|
||||||
|
|
||||||
## Modules
|
## Modules
|
||||||
|
|
||||||
There are various modules and package managers to install these for python like
|
There are various modules and package managers to install these for python like
|
||||||
@@ -87,7 +127,9 @@ If it doesnt work the packages can be installed globally using `pip` together wi
|
|||||||
`--break-system-packages` flag.
|
`--break-system-packages` flag.
|
||||||
This flag is to be used with care.
|
This flag is to be used with care.
|
||||||
|
|
||||||
### Pytorch
|
### PyTorch
|
||||||
|
|
||||||
|
This section addresses the [PyTorch module](https://pytorch.org/).
|
||||||
|
|
||||||
#### Setup Pytorch with Cuda for GPU usage
|
#### Setup Pytorch with Cuda for GPU usage
|
||||||
|
|
||||||
@@ -107,3 +149,17 @@ torch.cuda.is_available()
|
|||||||
```
|
```
|
||||||
|
|
||||||
This should give back `True`.
|
This should give back `True`.
|
||||||
|
|
||||||
|
### TensorFlow
|
||||||
|
|
||||||
|
This section addresses the [TensorFlow module](https://www.tensorflow.org/).
|
||||||
|
|
||||||
|
#### Basic Usage of TensorFlow
|
||||||
|
|
||||||
|
The basic usage of TensorFlow is described in
|
||||||
|
[the official guide](https://www.tensorflow.org/guide/keras/serialization_and_saving).
|
||||||
|
Additionally it is noted that the dataset may have to be shuffled manually as described in a
|
||||||
|
[comment by Y. Luo on StackOverflow](https://stackoverflow.com/questions/50184144/shuffle-in-the-model-fit-of-keras).
|
||||||
|
Finally
|
||||||
|
[a Medium blog post](https://medium.com/@danielonugha0/how-to-change-the-learning-rate-of-tensorflow-b5d854819050)
|
||||||
|
describes how to easily change the learning rate.
|
||||||
|
|||||||
Reference in New Issue
Block a user