2019 DS / ML digest 12
Highlights of the week(s)
- Cool STT papers;
- End of AI hype?
- How to download tons of images from Google;
https://spark-in.me/post/2019_ds_ml_digest_12
#digest
#deep_learning
Highlights of the week(s)
- Cool STT papers;
- End of AI hype?
- How to download tons of images from Google;
https://spark-in.me/post/2019_ds_ml_digest_12
#digest
#deep_learning
Yeah, scraping image labels from Google / other social networks is a really cool idea ...
Installing apex ... in style )
Sometimes you just need to try fp16 training (GANs, large networks, rare cases).
There is no better way to do this than use Nvidia's APEX library.
Luckily - they have very nice examples:
- https://github.com/NVIDIA/apex/tree/master/examples/docker
Well ... it installs on a clean machine, but I want my environment to work with this always)
So, I ploughed through all the conda / environment setup mumbo-jumbo and created a version of our deep-learning / ds dockerfile, but now instlalling from pytorch image (pytorch GPU / CUDA / CUDNN + APEX).
- https://github.com/snakers4/gpu-box-setup/blob/master/dockerfile/Dockerfile_apex
It was kind of painful, because PyTorch images already contain conda / pip and it was not apparent at first, causing all sorts of problems with my miniconda instalation.
So use it and please report if it is still buggy.
#deep_learning
#pytorch
Sometimes you just need to try fp16 training (GANs, large networks, rare cases).
There is no better way to do this than use Nvidia's APEX library.
Luckily - they have very nice examples:
- https://github.com/NVIDIA/apex/tree/master/examples/docker
Well ... it installs on a clean machine, but I want my environment to work with this always)
So, I ploughed through all the conda / environment setup mumbo-jumbo and created a version of our deep-learning / ds dockerfile, but now instlalling from pytorch image (pytorch GPU / CUDA / CUDNN + APEX).
- https://github.com/snakers4/gpu-box-setup/blob/master/dockerfile/Dockerfile_apex
It was kind of painful, because PyTorch images already contain conda / pip and it was not apparent at first, causing all sorts of problems with my miniconda instalation.
So use it and please report if it is still buggy.
#deep_learning
#pytorch
GitHub
apex/examples/docker at master · NVIDIA/apex
A PyTorch Extension: Tools for easy mixed precision and distributed training in Pytorch - apex/examples/docker at master · NVIDIA/apex
Logging your hardware, with logs, charts and alers - in style
TLDR - we have been looking for THE software to do this easily, with charts / alerts / easy install.
We found prometheus. Configuring alerts was a bit of a problem, but enjoy:
- https://github.com/snakers4/gpu-box-setup#prometheus
#deep_learning
#hardware
TLDR - we have been looking for THE software to do this easily, with charts / alerts / easy install.
We found prometheus. Configuring alerts was a bit of a problem, but enjoy:
- https://github.com/snakers4/gpu-box-setup#prometheus
#deep_learning
#hardware
GitHub
GitHub - snakers4/gpu-box-setup
Contribute to snakers4/gpu-box-setup development by creating an account on GitHub.
Trying to migrate to JupyterLab from Jupyter Notebook?
Some time ago I noticed that the Jupyter extensions project was more or less frozen => JupyterLab obviously is trying to shift community attention to npm / nodejs plugins.
Again (like 6-12 months ago) I tried to do this.
This time Lab is more mature:
- Now at version >1;
- Now they have built-in package manager;
- They have some of the most necessary extensions (i.e. git, toc, google drive, etc);
- UI got polished a bit, but window in a window still produces a bit of mental friction. Only the most popular file formats are supported. Text editor inherited the best features, but it is still a bit rudimentary;
- Full screen width by default;
- Some useful things (like codefolding) are now turned on in settings json file;
- Using these extensions is a bit of a chore in edge cases (i.e. some user permission problems / you have to re-build an app each time you add an extensions);
But I could not switch mostly for one reason - this one
- https://github.com/jupyterlab/jupyterlab/issues/2275#issuecomment-498323475
If you have a Jupyter environment it is very easy to switch. For me, before it was:
And it just became:
#data_science
Some time ago I noticed that the Jupyter extensions project was more or less frozen => JupyterLab obviously is trying to shift community attention to npm / nodejs plugins.
Again (like 6-12 months ago) I tried to do this.
This time Lab is more mature:
- Now at version >1;
- Now they have built-in package manager;
- They have some of the most necessary extensions (i.e. git, toc, google drive, etc);
- UI got polished a bit, but window in a window still produces a bit of mental friction. Only the most popular file formats are supported. Text editor inherited the best features, but it is still a bit rudimentary;
- Full screen width by default;
- Some useful things (like codefolding) are now turned on in settings json file;
- Using these extensions is a bit of a chore in edge cases (i.e. some user permission problems / you have to re-build an app each time you add an extensions);
But I could not switch mostly for one reason - this one
- https://github.com/jupyterlab/jupyterlab/issues/2275#issuecomment-498323475
If you have a Jupyter environment it is very easy to switch. For me, before it was:
# 5.6 because otherwise I have a bug with installing extensions
RUN conda install notebook=5.6
RUN pip install git+https://github.com/ipython-contrib/jupyter_contrib_nbextensions && \
jupyter contrib nbextension install --user
CMD jupyter notebook --port=8888 --ip=0.0.0.0 --no-browser
And it just became:
RUN conda install -c conda-forge jupyterlab
CMD jupyter lab --port=8888 --ip=0.0.0.0 --no-browser
#data_science
GitHub
Support collapsible hierarchy of sections · Issue #2275 · jupyterlab/jupyterlab
Allow users to toggle open/close sections by clicking on some kind of UI element. This helps with navigating and organizing large notebooks.
Full IDE in a browser?
Almost)
You all know all the pros and cons of:
- IDEs (PyCharm);
- Advanced text editors (Atom, Sublime Text);
- Interactive environments (notebook / lab, Atom + Hydrogen);
I personally dislike local IDEs - not because connecting to a remote / remote kernel / remote interpreter is a bit of a chore. Setting up is easy, but always thinking about what is synced and what is not - is just pain. Also when your daily driver machine is on Windows, using Linux subsystem all the time with Windows paths is just pain. (Also I diskile bulky interfaces, but this is just a habit and it depends).
But what if I told you there is a third option? =)
If you work as a team on a remote machine / set of machines?
TLDR - you can run a modern web "IDE" (it is something between Atom and real IDE - less bulky, but less functions) in a browser.
Now you can just run it with one command.
Pros:
- It is open source (though shipped as a part of some enterprise packages like Eclipse Che);
- Pre-built images available;
- It is extendible - new modules get released - you can build yourself or just find a build;
- It has extensive linting, python language server (just a standard library though);
- It has full text search ... kind of;
- Follow definition in your code;
- Docstrings and auto-complete work for your modules and standard library (not for you packages);
Looks cool af!
If they ship a build with a remote python kernel, then it will be a perfect option for teams!
I hope it will not follow a path taken by another crowd favourite similar web editor (it was purhcased by Amazon).
Links
- Website;
- Pre-built apps for python;
- Language server they are using;
#data_science
Almost)
You all know all the pros and cons of:
- IDEs (PyCharm);
- Advanced text editors (Atom, Sublime Text);
- Interactive environments (notebook / lab, Atom + Hydrogen);
I personally dislike local IDEs - not because connecting to a remote / remote kernel / remote interpreter is a bit of a chore. Setting up is easy, but always thinking about what is synced and what is not - is just pain. Also when your daily driver machine is on Windows, using Linux subsystem all the time with Windows paths is just pain. (Also I diskile bulky interfaces, but this is just a habit and it depends).
But what if I told you there is a third option? =)
If you work as a team on a remote machine / set of machines?
TLDR - you can run a modern web "IDE" (it is something between Atom and real IDE - less bulky, but less functions) in a browser.
Now you can just run it with one command.
Pros:
- It is open source (though shipped as a part of some enterprise packages like Eclipse Che);
- Pre-built images available;
- It is extendible - new modules get released - you can build yourself or just find a build;
- It has extensive linting, python language server (just a standard library though);
- It has full text search ... kind of;
- Follow definition in your code;
- Docstrings and auto-complete work for your modules and standard library (not for you packages);
Looks cool af!
If they ship a build with a remote python kernel, then it will be a perfect option for teams!
I hope it will not follow a path taken by another crowd favourite similar web editor (it was purhcased by Amazon).
Links
- Website;
- Pre-built apps for python;
- Language server they are using;
#data_science
www.theia-ide.org
Theia - Cloud and Desktop IDE
Theia is an open-source cloud desktop IDE framework implemented in TypeScript.
If you know how to add your python kernel to Theia - please ping me)
An ideal remote IDE?
Joking?
No, looks like VScode recently got its remote development extensions (it was only in insiders build a couple of months ago) working just right.
I tried remote-ssh extension and it looks quite polished. No syncing your large data folders and loading all python dependencies locally for hours.
The problem? It took me an hour just to open ssh session under Windows properly (permissions and Linux folder path substitution is hell on Windows). When I opened it - it worked like a charm.
So for now (it is personal) - best tools are in my opinion:
- Notebooks - for exploration and testing;
- VScode for codebase;
- Atom - for local scripts;
#data_science
Joking?
No, looks like VScode recently got its remote development extensions (it was only in insiders build a couple of months ago) working just right.
I tried remote-ssh extension and it looks quite polished. No syncing your large data folders and loading all python dependencies locally for hours.
The problem? It took me an hour just to open ssh session under Windows properly (permissions and Linux folder path substitution is hell on Windows). When I opened it - it worked like a charm.
So for now (it is personal) - best tools are in my opinion:
- Notebooks - for exploration and testing;
- VScode for codebase;
- Atom - for local scripts;
#data_science
Visualstudio
Visual Studio Code Remote Development
Managing your DS / ML environment neatly and in style
If you have a sophisticated environment that you need to do DS / ML / DL, then using a set of Docker images may be a good idea.
You can also tap into a vast community of amazing and well-maintained Dockerhub repositories (e.g. nvidia, pytorch).
But what you have to do this for several people? And use it with a proper IDE via ssh?
A well-known features of Docker include copy on write and user "forwarding". If you approach naively, each user will store his own images, which take quite some space.
And also you have to make your ssh daemon works inside of a container as a second service.
So I solved these "challenges" and created 2 public layers so far:
- Basic DS / ML layer -
- DS / ML libraries -
Your final dockerfile may look something like this just pulling from any of those layers.
Note that when building this, you will need to pass your
When launched, this launched a notebook with extensions. You can just
#deep_learning
#data_science
If you have a sophisticated environment that you need to do DS / ML / DL, then using a set of Docker images may be a good idea.
You can also tap into a vast community of amazing and well-maintained Dockerhub repositories (e.g. nvidia, pytorch).
But what you have to do this for several people? And use it with a proper IDE via ssh?
A well-known features of Docker include copy on write and user "forwarding". If you approach naively, each user will store his own images, which take quite some space.
And also you have to make your ssh daemon works inside of a container as a second service.
So I solved these "challenges" and created 2 public layers so far:
- Basic DS / ML layer -
FROM aveysov/ml_images:layer-0
- from dockerfile;- DS / ML libraries -
FROM aveysov/ml_images:layer-0
- from dockerfile;Your final dockerfile may look something like this just pulling from any of those layers.
Note that when building this, you will need to pass your
UID
as a variable, e.g.:docker build --build-arg NB_UID=1000 -t av_final_layer -f Layer_final.dockerfile .
When launched, this launched a notebook with extensions. You can just
exec
into the machine itself to run scripts or use an ssh
daemon inside (do not forget to add your ssh key and service ssh start
).#deep_learning
#data_science
GitHub
gpu-box-setup/Layer0_gpu_base_apex_python.dockerfile at master · snakers4/gpu-box-setup
Contribute to snakers4/gpu-box-setup development by creating an account on GitHub.
Using public Dockerhub account for your private small scale deploy
Also a lifehack - you can just use Dockerhub for your private stuff, just separate the public part and the private part.
Push the public part (i.e. libraries and frameworks) to Dockerhub/
You private Dockerfile will be then something like:
Also a lifehack - you can just use Dockerhub for your private stuff, just separate the public part and the private part.
Push the public part (i.e. libraries and frameworks) to Dockerhub/
You private Dockerfile will be then something like:
FROM your_user/your_repo:latest
COPY your_app_folder your_app_folder
COPY app.py app.py
EXPOSE 8000
CMD ["python3", "app.py"]
PyTorch 1.2 release
Link
Key features:
- Tensorboard logging in now out of beta;
- They continue improving JIT and ONNX;
- NN.Transformer is a layer now;
- Looks like SyncBn is also more or less stable;
- nn.Embedding: support float16 embeddings on CUDA;
- AdamW;
- Numpy compatibility;
#deep_learning
Link
Key features:
- Tensorboard logging in now out of beta;
- They continue improving JIT and ONNX;
- NN.Transformer is a layer now;
- Looks like SyncBn is also more or less stable;
- nn.Embedding: support float16 embeddings on CUDA;
- AdamW;
- Numpy compatibility;
#deep_learning
GitHub
Release New TorchScript API with Improved Python Language Coverage, Expanded ONNX Export, NN.Transformer · pytorch/pytorch
We have just released PyTorch v1.2.0.
It has over 1,900 commits and contains a significant amount of effort in areas spanning JIT, ONNX, Distributed, as well as Performance and Eager Frontend Impro...
It has over 1,900 commits and contains a significant amount of effort in areas spanning JIT, ONNX, Distributed, as well as Performance and Eager Frontend Impro...
Extreme NLP network miniaturization
Tried some plain RNNs on a custom in the wild NER task.
The dataset is huge - literally infinite, but manually generated to mimick in-the-wild data.
I use EmbeddingBag + 1m n-grams (an optimal cut-off). Yeah, on NER / classification it is a handy trick that makes your pipeline totally misprint / error / OOV agnostic. Also FAIR themselves just guessed this too. Very cool! Just add PyTorch and you are golden.
What is interesting:
- Model works with embedding sizes 300, 100, 50 and even 5! 5 is dangerously close to OHE, but doing OHE on 1m n-grams kind-of does not make sense;
- Model works with various hidden sizes
- Naturally all of the models run on CPU very fast, but the smallest model also is very light in terms of its weights;
- The only difference is - convergence time. It kind of scales as a log of model size, i.e. model with 5 takes 5-7x more time to converge compared to model with 50. I wonder what if I use embedding size of 1?;
As added bonus - you can just store such miniature model in git w/o lfs.
What is with training transformers on US$250k worth of compute credits you say?)
#nlp
#data_science
#deep_learning
Tried some plain RNNs on a custom in the wild NER task.
The dataset is huge - literally infinite, but manually generated to mimick in-the-wild data.
I use EmbeddingBag + 1m n-grams (an optimal cut-off). Yeah, on NER / classification it is a handy trick that makes your pipeline totally misprint / error / OOV agnostic. Also FAIR themselves just guessed this too. Very cool! Just add PyTorch and you are golden.
What is interesting:
- Model works with embedding sizes 300, 100, 50 and even 5! 5 is dangerously close to OHE, but doing OHE on 1m n-grams kind-of does not make sense;
- Model works with various hidden sizes
- Naturally all of the models run on CPU very fast, but the smallest model also is very light in terms of its weights;
- The only difference is - convergence time. It kind of scales as a log of model size, i.e. model with 5 takes 5-7x more time to converge compared to model with 50. I wonder what if I use embedding size of 1?;
As added bonus - you can just store such miniature model in git w/o lfs.
What is with training transformers on US$250k worth of compute credits you say?)
#nlp
#data_science
#deep_learning
Facebook
A new model for word embeddings that are resilient to misspellings
Misspelling Oblivious Embeddings (MOE) is a new model for word embeddings that are resilient to misspellings, improving the ability to apply word embeddings to real-world situations, where misspellings are common.
My foray into the STT Dark Forest
My tongue-in-cheek article on ML in general, and how to make your STT model train 3-4x faster with 4-5x less weights with the same quality
https://spark-in.me/post/stt-dark-forest
#data_science
#deep_learning
#stt
My tongue-in-cheek article on ML in general, and how to make your STT model train 3-4x faster with 4-5x less weights with the same quality
https://spark-in.me/post/stt-dark-forest
#data_science
#deep_learning
#stt
Sampler - visualization for any shell command
A cool mix between glances and prometheus
https://github.com/sqshq/sampler
#linux
A cool mix between glances and prometheus
https://github.com/sqshq/sampler
#linux
GitHub
GitHub - sqshq/sampler: Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file.
Tool for shell commands execution, visualization and alerting. Configured with a simple YAML file. - sqshq/sampler
2019 DS / ML digest 14
Link
Highlights of the week(s):
- FAIR embraces embedding bags for misspellings;
- New version of Adam - RAdam. But on the only real test author has concluded (Imagenet) - SGD is better;
- Yet another LSTM replacement - SRU. Similar to QRRN - it requires additional dependencies;
#digest
#deep_learning
Link
Highlights of the week(s):
- FAIR embraces embedding bags for misspellings;
- New version of Adam - RAdam. But on the only real test author has concluded (Imagenet) - SGD is better;
- Yet another LSTM replacement - SRU. Similar to QRRN - it requires additional dependencies;
#digest
#deep_learning
Our STT Dark Forest post on TDS
https://towardsdatascience.com/navigating-the-speech-to-text-dark-forest-b511e6e7aa88?source=friends_link&sk=d46e5b96aaa7e94f337cc6e2e540545b
Please 👏x50 if you have an account
#deep_learning
https://towardsdatascience.com/navigating-the-speech-to-text-dark-forest-b511e6e7aa88?source=friends_link&sk=d46e5b96aaa7e94f337cc6e2e540545b
Please 👏x50 if you have an account
#deep_learning
Medium
Navigating the Speech to Text Dark Forest
Make your ASR network 4x faster, 5x smaller and 10x cooler
How to solve an arbitrary CV task ...
- W/o annotation
- W/o GPUs in production
- And make your model work in real life and help people
https://spark-in.me/post/deploy_classifier
https://medium.com/@slizhikova.a.v/how-to-get-your-own-image-classifier-region-labelling-model-without-annotation-d95aabbd8599?sk=fd844bf2a6f48171f02cbbda7bc493a6
#deep_learning
#computer_vision
- W/o annotation
- W/o GPUs in production
- And make your model work in real life and help people
https://spark-in.me/post/deploy_classifier
https://medium.com/@slizhikova.a.v/how-to-get-your-own-image-classifier-region-labelling-model-without-annotation-d95aabbd8599?sk=fd844bf2a6f48171f02cbbda7bc493a6
#deep_learning
#computer_vision
Poor man's ensembling techniques
So you want to improve your model's performance a bit.
Ensembling helps. But as is ... it's useful only on Kaggle competitions, where people stack over9000 networks trained on 100MB of data.
But for real life usage / production, there exist ensembling techniques, that do not require significant computation cost increase (!).
All of this is not mainstream yet, but it may work on you dataset!
Especially if your task is easy and the dataset is small.
- SWA (proven to work, usually used as a last stage when training a model);
- Lookahead optimizer (kind of new, not thoroughly tested);
- Multi-Sample Dropout (seems like a cheap ensemble, should work for classification);
Applicability will vary with your task.
Plain vanilla classification can use all of these, s2s networks probably only partially.
#data_science
#deep_learning
So you want to improve your model's performance a bit.
Ensembling helps. But as is ... it's useful only on Kaggle competitions, where people stack over9000 networks trained on 100MB of data.
But for real life usage / production, there exist ensembling techniques, that do not require significant computation cost increase (!).
All of this is not mainstream yet, but it may work on you dataset!
Especially if your task is easy and the dataset is small.
- SWA (proven to work, usually used as a last stage when training a model);
- Lookahead optimizer (kind of new, not thoroughly tested);
- Multi-Sample Dropout (seems like a cheap ensemble, should work for classification);
Applicability will vary with your task.
Plain vanilla classification can use all of these, s2s networks probably only partially.
#data_science
#deep_learning
PyTorch
Stochastic Weight Averaging in PyTorch
In this blogpost we describe the recently proposed Stochastic Weight Averaging (SWA) technique [1, 2], and its new implementation in torchcontrib. SWA is a simple procedure that improves generalization in deep learning over Stochastic Gradient Descent (SGD)…
ML without train / val split
Yeah, I am not crazy. But probably this applies only to NLP.
Sometimes you just need your pipeline to be flexible enough to work with any possible "in the wild" data.
A cool and weird trick - if you can make your dataset so large that your model just MUST generalize to work on it, then you do not need a validation set.
If you sample data randomly and your data generator is good enough, each new batch is just random and can serve as validation.
#deep_learning
Yeah, I am not crazy. But probably this applies only to NLP.
Sometimes you just need your pipeline to be flexible enough to work with any possible "in the wild" data.
A cool and weird trick - if you can make your dataset so large that your model just MUST generalize to work on it, then you do not need a validation set.
If you sample data randomly and your data generator is good enough, each new batch is just random and can serve as validation.
#deep_learning