Skip to content

Instantly share code, notes, and snippets.

💭
Using human learning for machine learning

Tom Hale HaleTom

💭
Using human learning for machine learning
Block or report user

Report or block HaleTom

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@HaleTom
HaleTom / keybase.md
Created Sep 11, 2019
Keybase identity proof
View keybase.md

Keybase proof

I hereby claim:

  • I am haletom on github.
  • I am tomhale (https://keybase.io/tomhale) on keybase.
  • I have a public key ASA0UCq38IWRstxf9o5_HXYCzXjb7paM7SF7QfHRykoxsAo

To claim this, I am signing this object:

@HaleTom
HaleTom / nnCostFunction.m
Created Jul 9, 2019
Matlab gradient descent - Coursera's Machine Learning ex4/nnCostFunction.m
View nnCostFunction.m
function [J grad] = nnCostFunction(nn_params, ...
input_layer_size, ...
hidden_layer_size, ...
num_labels, ...
X, Y, lambda)
%NNCOSTFUNCTION Implements the neural network cost function for a two layer
%neural network which performs classification
% [J grad] = NNCOSTFUNCTON(nn_params, hidden_layer_size, num_labels, ...
% X, y, lambda) computes the cost and gradient of the neural network. The
% parameters for the neural network are "unrolled" into the vector
@HaleTom
HaleTom / describe.m
Last active Jul 9, 2019
Matlab/Octave: describe a variable (name, type, size)
View describe.m
% Based upon https://stackoverflow.com/a/45347880/5353461
% Gist at: https://gist.github.com/HaleTom/533b0ed7c51f93bfb5f71007a188bac4
function varargout = describe(varargin)
% varargin used to accommodate variable number of input names
st = dbstack;
outstring = '';
for ii = size(st, 1):-1:2
outstring = [outstring, st(ii).file, ' > ', st(ii).name, ', line ', num2str(st(ii).line), '\n'];
end
@HaleTom
HaleTom / describe.py
Last active Mar 29, 2018
describe - line and filename, variable name, class, str representation and some other info
View describe.py
# Print the line and filename, function call, the class, str representation and some other info
# Inspired by https://stackoverflow.com/a/8856387/5353461
import inspect
import re
def describe(arg):
frame = inspect.currentframe()
callerframeinfo = inspect.getframeinfo(frame.f_back)
@HaleTom
HaleTom / Test.ipynb
Last active Nov 25, 2017
Test .ipynb
View Test.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@HaleTom
HaleTom / pacman-backup
Last active Mar 9, 2017
Safely backup pacman's sync databases
View pacman-backup
#!/bin/bash
# Safely backup the pacman databases to enable reversal of system upgrade.
# Use pacman -b <backupdirectory> to use the saved databses
# Latest version: https://gist.github.com/HaleTom/9dbffaf3369b86ca272ffe6a61a36aba
set -euo pipefail; shopt -s failglob # safe mode
db_lock=/var/lib/pacman/db.lck
@HaleTom
HaleTom / update_table
Created Oct 4, 2016
Update vim's ":help compatible" table from source code extract
View update_table
#!/bin/bash -eu
table_to_update=./compatible_table
source_extract=./option_extract
function get_decorated_options {
# option_extract > while read -r option;
while read -r line; do
name=$(printf %s "$line" | sed -rn 's/^\s*\{\s*"(\w+).*/\1/p')
# Get decoration
@HaleTom
HaleTom / git-quote-string-multiline
Created Oct 1, 2016
Quote a single- or multi-line string for use in git's aliases
View git-quote-string-multiline
#!/bin/bash -eu
# Quote a single- or multi-line string for use in git's aliases
# Copyright (c) 2016 Tom Hale under https://en.wikipedia.org/wiki/MIT_License
quote() {
printf %s "$1" | sed -r 's/(["\\])/\\\1/g';
}
IFS=$(printf '\n')
@HaleTom
HaleTom / print256colours.sh
Last active Oct 2, 2019
Print a 256-colour test pattern in the terminal
View print256colours.sh
#!/bin/bash
# Tom Hale, 2016. MIT Licence.
# Print out 256 colours, with each number printed in its corresponding colour
# See http://askubuntu.com/questions/821157/print-a-256-color-test-pattern-in-the-terminal/821163#821163
set -eu # Fail on errors or undeclared variables
printable_colours=256
@HaleTom
HaleTom / .bash_funcs
Created Aug 30, 2016
My bash shell functions
View .bash_funcs
# Functions to be sourced by .bashrc
#
# Ensure that ones to be accessed outside of .bashrc are added
# to the 'export' line at the very end.
# The absolute directory name of a file(s) or directory(s)
function abs_dirname {
for _ in $(eval echo "{1..$#}"); do
(cd "${dir:="$(dirname "$1")"}" && pwd || exit 1 )
[[ $? -ne 0 ]] && return 1
You can’t perform that action at this time.