From Generalization to Inner Activations
One of the side effects of deep learning models becoming increasingly large is the amount of data that they intermediately generate which is then often ignored. Researchers have used this information to create explainability methods which show importance relative to a specific input it is connected with, but often the intermediate values are disregarded and mostly underutilized. Although this intermediate data can become increasingly unwieldily in size as the networks grow, the ability to monitor specific layers is a valuable tool that provides insight into how the model is learning as well as vague generalities about how the model performs overall (e.g. where are specific features begun to be extracted or where is noise filtered out).
sending objects/files over websockets
Updates
1/24/23 Ran into this library cloudpickle and it reminded me of this post.
3/18/21: Found this outrun which seems to be basically a better and more thought out way to do a lot of this.
Introduction
Recently I became interested in better workflows for machine learning projects. One of the main issues I’ve experienced is developing locally but not being able to easily test locally. Generally this is from a local computer being a bit slower and older for the types of models and datasets I am working with and initial code decisions that resulted in poor performance on a slower computer than the server used to train. Another instance I have had this happen is if the remote server is behind a VPN and a relay hop and there is a bit of a latency between saving the file and running it if I am using something such as VSCode (although you can try something such as a ProxyJump in your ssh config). Regardless of the problem, I have yet to find an actual workflow that I find versatile and simple.
Tcav 101
TCAV Introduction
Understanding deep learning models remains an open challenge in machine learning research. The concept of “understanding” itself is subjective and varies significantly depending on one’s technical background and perspective. This complexity is frequently addressed in research papers, where different approaches to model interpretability yield different insights.
What makes a model truly interpretable? Several excellent blog posts have explored this question:
While these resources offer valuable perspectives on model interpretation, TCAV (Testing with Concept Activation Vectors) takes a unique approach. It builds on the observation that specific neural network layers become activated by distinct features or “concepts” more than others.
using fastText to classify phone call dialogue
fastText: A Short Guide
fastText is a powerful, open-source library designed to facilitate both supervised and unsupervised learning of text representations and classifiers. Unlike other tools like sklearn or spaCy, fastText is particularly praised for its speed and ease of use, which make it accessible even for those with limited technical background. The official fastText website describes it as “lightweight” and capable of running on “standard, generic hardware,” with the potential to optimize models for mobile devices.
using kubernete jobs for one off ingestion of csv's
Running Postgres on kubernetes locally
While setting up Kubernetes locally might seem like overkill for one off data ingestion tasks, it provides several advantages:
- Creates a consistent development environment that mirrors production
- Allows testing of Kubernetes configurations before cloud deployment
- Enables development of microservices in isolation
- Provides a foundation for scaling your ML pipeline
For this tutorial, we’ll use Docker for Mac with its built-in Kubernetes support (v1.9.8). This setup offers a straightforward development experience with modern Kubernetes tooling while maintaining compatibility with cloud deployments. Though alternatives like Docker Swarm or Compose are a few years old now, Kubernetes provides a platform for building and managing data pipelines that can help ease the transition from local development to prod deployments.
downloading files from kaggle
Often it can be a hassle to get files from kaggle to a remote server.
Previously I had used cookies from chrome to allow me to download files or a python command line module that allowed me to specify the competition, neither of these work efficiently and are clunky/prone to breaking. I had been meaning to write a script to do this for some time now had never gotten around to it. Finally I did it and here it is posted, this is also incredibly useful for downloading files that are locked away by login/password on some site. For this, I am using RoboBrowser.
telegram bot
Setting up a Telegram Bot in Python and Docker
This post is my personal introduction to using Telegram and Bluemix and while it is incredibly simple, it is useful to see how to do the basics before integrating peripheral API’s or extraneous processes.
First, set up a telegram account however you’d like. I used Desktop client and it worked great. Once you have an account, you need to interact with @BotFather to set up a bot. Message @BotFather /start and you will receive these options:
TensorFlow 0.7.0 dockerfile with Python 3
edit: everything has since been updated to Tensorflow 0.7.0 which I based off of my base cuda dockerfile to use with tensorflow or theano (depending on my goals, Keras allows great flexibility in between training vs compiling)
TensorFlow
In 2015 Google came out with a new deep learning framework/tensor library similar in many ways to Theano and I enjoy using it a lot more than Theano simply due to long compile times of Theano when using Keras and TensorBoard. This will not go into detail about using Theano or TensorFlow or Keras but instead is how I built a docker image that uses a slightly older nvidia card (which for my purposes is capable of using multiple gpu’s in isolation and exiting a model on one card and not effecting the other).
using generative neural nets in keras to create ‘on-the-fly’ dialogue
Updates
6/6/23 A question was recently asked about this post, but the original code here is no longer functional. It was created with limited programming experience and remains only for historical reference.
4/10/17 Most python modules have changed significantly since this was written, causing issues with youtube-dl and keras. Anyone working on or possessing an updated version is encouraged to get in touch.