Skip to content

Instantly share code, notes, and snippets.

View yoyolicoris's full-sized avatar
😴
Back at home

Scusk Rimsi yoyolicoris

😴
Back at home
View GitHub Profile
@kiang
kiang / compare.csv
Created April 4, 2021 14:54
compare traffic accidents between Taiwan & Japan
台灣事故件數(件) 台灣死亡人數(人) 台灣受傷人數(人) 日本事故件數(件) 日本死亡人數(人) 日本受傷人數(人)
2008 170127 3474 226192 766394 5209 945703
2009 184749 3232 245837 737637 4979 911215
2010 219651 3297 292535 725924 4948 896297
2011 235776 3343 314004 692084 4691 854613
2012 249465 3219 332942 665157 4438 825392
2013 278388 3072 372443 629033 4388 781492
2014 307842 3075 412010 573842 4113 711374
2015 305413 2942 408860 536899 4117 666023
2016 305556 2847 402699 499201 3904 618853
@unixpickle
unixpickle / maml.py
Created October 12, 2019 19:08
MAML in PyTorch
import torch
import torch.nn.functional as F
def maml_grad(model, inputs, outputs, lr, batch=1):
"""
Update a model's gradient using MAML.
The gradient will point in the direction that
improves the total loss across all inner-loop
@mikehamer
mikehamer / pytorch_custom_backward.cpp
Created April 9, 2019 13:28
An example of using the PyTorch C++ API to implement a custom forward and backward function
// An example of using the PyTorch C++ API to implement a custom forward and backward function
#include <iostream>
#include <vector>
#include <torch/torch.h>
#include <torch/csrc/autograd/variable.h>
#include <torch/csrc/autograd/function.h>
#include <torch/csrc/autograd/VariableTypeUtils.h>
#include <torch/csrc/autograd/functions/utils.h>
@dojoteef
dojoteef / profile.py
Last active June 5, 2023 11:44
A CUDA memory profiler for pytorch
'''
Memory profiling utilities
'''
import gc
import inspect
import linecache
import os.path
import sys
import time
import threading
@carlthome
carlthome / Signal reconstruction from spectrograms.ipynb
Created May 31, 2018 13:53
Try to recover audio from filtered magnitudes when phase information has been lost.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jojonki
jojonki / ema.py
Last active March 13, 2020 05:18
Apply exponential moving average decay for variables in PyTorch
# How to apply exponential moving average decay for variables?
# https://discuss.pytorch.org/t/how-to-apply-exponential-moving-average-decay-for-variables/10856/2
class EMA(nn.Module):
def __init__(self, mu):
super(EMA, self).__init__()
self.mu = mu
def forward(self,x, last_average):
new_average = self.mu*x + (1-self.mu)*last_average
return new_average
@f0k
f0k / nvidia_boost.sh
Created December 6, 2017 17:45
Set Nvidia GPU application clocks and power limits to maximum supported values
#!/bin/bash
# Sets each CUDA device to persistence mode and sets the application clock
# and power limit to the device's maximum supported values.
# When run with "--dry-run" as first command line argument or not as superuser,
# will display the commands, otherwise it will execute them.
#
# Hint: To run this at boot time, place this script in /root and create a file
# /etc/cron.d/nvidia_boost with the following single line:
# @reboot root /root/nvidia_boost.sh >/dev/null
#
@DanielArnett
DanielArnett / vive-tracker-ubuntu-instructions.md
Last active July 18, 2024 03:38
How to use the HTC Vive Trackers in Ubuntu using Python 3.6.

This tutorial will guide you through the setup of the HTC Vive Tracker in Python 3.6 on Ubuntu 14.04.

Prerequesites

Up to date graphics drivers

x86 architecture

SteamVR requires >4GB disk space

@billju
billju / Drumpad.cpp
Last active October 21, 2021 01:58
/*
Super Easy Diy Drumpad Example
GIT: https://gist.github.com/billju/ce1337ea3c1dbb4341ce22dca1b55442
2017 by Billju
Inspired by Evan Kale
*/
#include <Keyboard.h>
#include "MIDIUSB.h"