Skip to content

Instantly share code, notes, and snippets.


Mike Clark wassname

Block or report user

Report or block wassname

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
wassname /
Last active May 31, 2019
Running stats (mean, standard deviation) for python, pytorch, etc
import numpy as np
# handle pytorch tensors etc, by using tensorboardX's method
from tensorboardX.x2num import make_np
except ImportError:
def make_np(x):
return np.array(x).copy().astype('float16')
class RunningStats(object):
class RunningMean(object):
def __init__(self, sum=0, i=0):
self.sum = sum
self.i = i
def __add__(self, other):
return RunningMean(self.sum+other, self.i+1)
def add(self, loss):
wassname /
Last active May 19, 2019
Transformer in ~80 lines of code from Thomas Wolf's tweet
Transformer in ~80 lines of code.
From Thomas Wolf's tweet
import torch
from torch import nn
class Transformer(nn.Module):
wassname /
Last active Mar 15, 2019
jaccard_distance_loss for pytorch
class JaccardDistanceLoss(torch.nn.Module):
def __init__(self, smooth=100, dim=1, size_average=True, reduce=True):
Jaccard = (|X & Y|)/ (|X|+ |Y| - |X & Y|)
= sum(|A*B|)/(sum(|A|)+sum(|B|)-sum(|A*B|))
The jaccard distance loss is usefull for unbalanced datasets. This has been
shifted so it converges on 0 and is smoothed to avoid exploding or disapearing
wassname /
Last active Mar 14, 2019
xubuntu on a Thinkpad Yoga x380

This are a collection of fixes and tweaks I used to get Xubuntu 18.04 LTS working on a lenovo thinkpad X380 yoga laptop.

View Samsung Smart-TV Blocklist Adlist (for PiHole)
# This is a blocklist to block samsung smart tv's sending meta data at home.
# Please help to collect domains!
# It could be that the TV does not receive any more updates or other services no longer work. Please report such an incident.
wassname / pytorch_losses.ipynb
Created Sep 25, 2018
Comparing the shape of mse, l1 (mae), smoothl1loss etc in pytorch as they approach 0 error
View pytorch_losses.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View LG Smart-TV Blocklist Adlist (for PiHole)
# added after fork
# from and others
wassname /
Created Sep 15, 2018
Scraping user flairs from TheCulture subreddit
# coding: utf-8
import praw
import json
from tqdm import tqdm
# I store my secret here and .gitignore it rather than risk commiting passwords
secrets = json.load(open('.secrets/reddit.json'))
userAgent = ' (by {})'.format(secrets['username'])
reddit = praw.Reddit(user_agent=userAgent, **secrets)
wassname / sampling_multiple_ordered_seqs.ipynb
Created Sep 2, 2018
example of sampling_multiple_ordered_seqs
View sampling_multiple_ordered_seqs.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.