{{ message }}

Instantly share code, notes, and snippets.

# David Warde-Farley dwf

Created Mar 21, 2022
Makefile for flashing a nanoCUL stick with the latest version of the evofw3 firmware.
View flash-nanocul-evofw3.mk
This file contains 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
 # Copyright 2022 Google LLC. # SPDX-License-Identifier: Apache-2.0 # # Makefile for flashing a nanoCUL stick with evofw3 using arduino-cli. # # Get arduino-cli and make with nix shell nixpkgs#gnumake nixpkgs#arduino-cli. # Then run make -f flash-nanocul.mk. # One of atmega328p, atmega32u4. Only tested with atmega328p, the one I have. BOARD=atmega328p
Created Aug 28, 2018
Autofill CoventryBS's silly 2FA with Bitwarden regex custom fields.
View coventry_regex.py
This file contains 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
 """ Take in a CoventryBS grid card as a text file, output regex custom fields for Bitwarden to autofill your grid card challenge for you. """ from __future__ import print_function import fileinput import itertools import sys COLS = 'ABCDEFGHIJ'
Created Apr 10, 2017
Stable binary cross-entropy, operating on logit predictions instead of relying on Theano to correctly optimize the sigmoid output.
View bcefl.py
This file contains 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
 from theano import tensor def binary_crossentropy_from_logits(logits, targets): """Binary cross-entropy computed from model logits. Parameters ---------- predictions : TensorVariable The unnormalized log probabilities of a probabilistic binary classifier. targets : TensorVariable
Created Jan 20, 2017
Single-script Blocks reproduction of the Goodfellow et al (2014) MNIST GAN.
View simple_mnist_gan.py
This file contains 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
 from collections import OrderedDict from blocks.algorithms import GradientDescent, Momentum from blocks.bricks import ( MLP, Rectifier, Logistic, Linear, LinearMaxout, Sequence, Random ) from blocks.extensions import Printing, Timing from blocks.extensions.training import SharedVariableModifier from blocks.extensions.monitoring import (DataStreamMonitoring, TrainingDataMonitoring)
Created Oct 12, 2016
Example of interleaving data streams with Fuel and conditional processing with Blocks.
View interleaved.ipynb
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Created Oct 9, 2016
Easily forward ports through an SSH login node.
View sshft.sh
This file contains 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
 sshft() { if [ $# -lt 2 ]; then echo "usage: sshft host [port|local:remote|local:bridge:remote] ...]" return 1 fi if [ -z "$DEFAULT_SSH_PROXY_HOST" ]; then echo "No DEFAULT_SSH_PROXY_HOST set." return 1 fi FIRST_SSH_ARGS="\$DEFAULT_SSH_PROXY_HOST"
Last active Dec 20, 2016
Minimal examples of using the Blocks MainLoop and checkpointing machinery.
View lib.py
This file contains 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
 # It's important not to define any classes you want serialized in # the script you're running as pickle doesn't like that (if you pass # save_main_loop=False to Checkpoint it's fine, though). from theano import tensor import numpy import theano from picklable_itertools import imap, izip, repeat # Your algorithm object just needs two required methods: initialize()
Created Sep 28, 2016
Fuel DataStream that segments the epochs of another DataStream.
View segmented_epoch_stream.py
This file contains 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
 """Fuel DataStream that segments the epochs of another DataStream.""" __license__ = """ Copyright (c) 2016 Universite de Montreal Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do
Created Apr 20, 2016
traceback of IPython caught in infinite corrupt DB handling loop
View gist:c659fdd50285b5a4885c10acc34b77e7
This file contains 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
 Traceback (most recent call last): File "/u/wardefar/miniconda/lib/python3.4/site-packages/IPython/core/history.py", line 85, in catch_corrupt_db return f(self, *a, **kw) File "/u/wardefar/miniconda/lib/python3.4/site-packages/IPython/core/history.py", line 227, in init_db end timestamp, num_cmds integer, remark text)""") sqlite3.OperationalError: disk I/O error During handling of the above exception, another exception occurred: Traceback (most recent call last):
Created Feb 17, 2016
Simplification of binary cross-entropy in terms of logits, yielding the familiar gradient.
View binary_cross_entropy.tex
This file contains 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
 \documentclass[12pt]{article} \usepackage{amsmath} \begin{document} \begin{eqnarray*} CE(a, t) & = & -t\log\left(\sigma(a)\right) - (1 - t)\log\left(1 - \sigma(a)\right) \\ & = & -t \log \left(\frac{1}{1 + \exp(a)}\right) - (1 - t)\log\left(1 - \frac{1}{1 + \exp(a)}\right) \\ & = & -t \log \left(\frac{1}{1 + \exp(a)}\right) - (1 - t)\log\left(\frac{\exp(a)}{1 + \exp(a)}\right) \\ & = & t \log \left(1 + \exp(a)\right) - \left[(1 - t)\log(\exp(a)) - \log(1 + \exp(a))\right] \\ &= & t \log \left(1 + \exp(a)\right) - (1 - t)\log(\exp(a)) + (1 - t)\log(1 + \exp(a)) \\