This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""MWE of a tensorboard setup with | |
- a dummy training and validation op | |
- loss for training and validation shown on the same graph | |
- histograms showing weights changing with training | |
To run tensorboard after running this script | |
$ tensorboard --log_dir=/tmp/tensorboard_demo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tensorflow 1.8.0 | |
import tensorflow as tf | |
import numpy as np | |
def save(dataset): | |
""" | |
Create graph with an Dataset and Iterator and save the model. | |
There is some op that is applied to the data from the iterator. | |
""" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Tensorflow 1.8.0 | |
import tensorflow as tf | |
import numpy as np | |
def make_iterators(train_dataset, test_dataset): | |
"""Creates the dataset iterators needed in train().""" | |
handle = tf.placeholder(tf.string, shape=[]) | |
tf.add_to_collection('handle', handle) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Simple example of various types of Tensorflow profiling. | |
Adapted from: | |
https://towardsdatascience.com/howto-profile-tensorflow-1a49fb18073d | |
https://www.tensorflow.org/api_docs/python/tf/profiler/Profiler | |
""" | |
from __future__ import absolute_import | |
from __future__ import division |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# View graphs with (Linux): $ tensorboard --logdir=/tmp/my_tf_model | |
import os | |
import tempfile | |
import tensorflow as tf | |
import numpy as np | |
from tensorboard import summary as summary_lib | |
from tensorboard.plugins.custom_scalar import layout_pb2 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
"""Runs autoflake on commit. Blocks commit and requests adding changed files | |
if autoflake fires. | |
Installation | |
------------ | |
1. You will need to install autoflake: https://pypi.org/project/autoflake/ | |
$ pip install --upgrade autoflake | |
or |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To be run in sudo's crontab. Access via sudo crontab -e | |
# You need to pick a channel first: | |
# $ echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list | |
# OR | |
# $ echo "deb https://download.sublimetext.com/ apt/dev/" | sudo tee /etc/apt/sources.list.d/sublime-text.list | |
echo $(date) | |
apt-get update && apt-get install sublime-text | |
apt autoremove -y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) | |
HISTSIZE=5000 | |
HISTFILESIZE=10000 | |
# Setup default editor | |
export EDITOR=subl | |
# Start ssh agent so can ssh to Git | |
eval "$(ssh-agent -s)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Toy example using DumpObject, a way of periodically dumping out large objects to | |
file as it grows. This example watches a file directory and creates a dictionary | |
with | |
* key: file name | |
* value: first line of file | |
Includes use of `watchdog` to watch for real time effects (here: new files | |
being created in the directory) and `atexit` to gracefully deal with the program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
""" | |
Checks file size of committed files. If there are stage files bigger than a | |
given size (`WARN_SIZE_MB`) then | |
* the commit is aborted | |
* you are told about the offending files | |
* you are told the command for forcing through the commit anyway | |
Save this file as "pre-commit" in your .git/hooks folder and do |
OlderNewer