Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
h = np.zeros(n) | |
z = np.zeros(n) | |
w = np.random.random(n) | |
beta = np.random.random(n) | |
alpha = np.exp(beta) | |
theta = np.random.random() | |
def autostep_tidbd_step(n, representation, S_t, S_tp1, C, gamma, w, h, z, alpha, tau, lmbda, zeta, rho, omega): | |
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
def loading_bar(i_step, _max, div=100, character='\u25A1'): | |
if not i_step % (_max // div): | |
print(character, end='' if i_step < ((_max // div) * div) else '\n', flush=True) | |
for i in range(200): | |
loading_bar(i, 200) |
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
import numpy as np | |
def calculate_discounted_return_backwards(value, gamma, normalize=True): | |
ret = np.zeros(value.shape[0]) # initialize the array we hold our values in | |
i = value.shape[0]-1 # starting at the end, heading backwards | |
while i >= 0: # until we reach the start of the array | |
ret[i] += value[i] # add the | |
try: # we surround in a try catch in case we are at the start | |
ret[i] += (ret[i+1] * gamma) # we add the previous return with a decay | |
except: # if there was no ret[i+1] |
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
def confusion_matrix(yt, yp, nc): | |
""" | |
Returns a confusion matrix in the same format as sklearn.metrics.confustion_matrix | |
:param yt: list of true labels | |
:param yp: list of predictions | |
:param nc: number of classes | |
""" | |
return [[sum(v == (j, i) for v in zip(yp, yt)) for j in range(nc)] for i in range(nc)] |
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 email.mime.text import MIMEText | |
from getpass import getpass | |
import smtplib | |
import argparse | |
class EmailLogger: | |
def __init__(self, subject, sender, receivers): | |
""" | |
Creates an EmailLogger object which can email messages from the sender to the reciever using gmail |
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
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' |
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
import random | |
get_colors = lambda n: list(map(lambda i: "#" + "%06x" % random.randint(0, 0xFFFFFF),range(n))) | |
winter = lambda n: [f'#00{"%02x"%(255-i)}{"%02x"%i}' for i in np.arange(1,255, 255/n, int)] | |
#import numpy as np | |
#get_colors = lambda n: list(map(lambda i: "#" + "%06x" % np.random.randint(0, 0xFFFFFF),range(n))) |
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
class Viking(object): | |
def __init__(self, arg): | |
if arg == 'add': | |
def dynamo(self, arg): | |
""" dynamo's a dynamic method! | |
""" | |
self.weight += 1 | |
return arg + self.weight | |
self.weight = 50 |
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
!#/bin/bash | |
# This utility script prints out a list associating what devices are on what ports. | |
for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do | |
( | |
syspath="${sysdevpath%/dev}" | |
devname="$(udevadm info -q name -p $syspath)" | |
[[ "$devname" == "bus/"* ]] && continue | |
eval "$(udevadm info -q property --export -p $syspath)" | |
[[ -z "$ID_SERIAL" ]] && continue | |
echo "/dev/$devname - $ID_SERIAL" |
NewerOlder