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
wassname / running_stats.py
Last active May 31, 2019
Running stats (mean, standard deviation) for python, pytorch, etc
View running_stats.py
import numpy as np
# handle pytorch tensors etc, by using tensorboardX's method
try:
from tensorboardX.x2num import make_np
except ImportError:
def make_np(x):
return np.array(x).copy().astype('float16')
class RunningStats(object):
View runningmean.py
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
wassname / simple_transformer.py
Last active May 19, 2019
Transformer in ~80 lines of code from Thomas Wolf's tweet https://twitter.com/Thom_Wolf/status/1129658539142766592
View simple_transformer.py
"""
Transformer in ~80 lines of code.
From Thomas Wolf's tweet https://twitter.com/Thom_Wolf/status/1129658539142766592.
"""
import torch
from torch import nn
class Transformer(nn.Module):
@wassname
wassname / jaccard_distance_loss.py
Last active Mar 15, 2019
jaccard_distance_loss for pytorch
View jaccard_distance_loss.py
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
gradient.
@wassname
wassname / linux_x380.md
Last active Mar 14, 2019
xubuntu on a Thinkpad Yoga x380
View linux_x380.md

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.
abtauthprd.samsungcloudsolution.com
acr0.samsungcloudsolution.com
ad.samsungadhub.com
ads.samsungads.com
amauthprd.samsungcloudsolution.com
api-hub.samsungyosemite.com
@wassname
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)
127.0.0.1 us.rdx2.lgtvsdp.com
127.0.0.1 us.info.lgsmartad.com
127.0.0.1 us.ibs.lgappstv.com
127.0.0.1 us.lgtvsdp.com
127.0.0.1 ad.lgappstv.com
127.0.0.1 smartshare.lgtvsdp.com
127.0.0.1 ibis.lgappstv.com
# added after fork
# from https://www.reddit.com/r/pihole/comments/6qmpv6/blacklists_for_lg_webos_tvs/ and others
@wassname
wassname / thecultureflairs.py
Created Sep 15, 2018
Scraping user flairs from TheCulture subreddit
View thecultureflairs.py
# 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 = 'python:thecultureflairs.py:v1.0 (by {})'.format(secrets['username'])
reddit = praw.Reddit(user_agent=userAgent, **secrets)
@wassname
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.