Skip to content

Instantly share code, notes, and snippets.

View cschell's full-sized avatar

Christian Rack cschell

View GitHub Profile
@cschell
cschell / custom_grid_sampler.py
Created January 28, 2022 08:50
custom version of Optuna's GridSampler, changing the default behaviour to ignore failed trials; the code only changes one line from the original (L23)
from typing import List
from optuna.samplers import GridSampler
from optuna.study import Study
from optuna.trial import TrialState
class CustomGridSampler(GridSampler):
def _get_unvisited_grid_ids(self, study: Study) -> List[int]:
# List up unvisited grids based on already finished ones.
losses = []
loss_function = nn.NLLLoss()
model = LeModel(len(vocab))
optimizer = optim.SGD(model.parameters(), lr=0.001)
for epoch in tqdm(range(1), leave=False):
total_loss = 0
for context, target in tqdm(data, leave=False):
model.zero_grad()
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
class CBOW(nn.Module):
def __init__(self, vocab_size: int, embedding_dim: int = 100, context_size: int = 4):
super(CBOW, self).__init__()
self.embeddings = nn.Embedding(vocab_size, embedding_dim)
self.linear1 = nn.Linear(context_size * embedding_dim, 128)
@cschell
cschell / Dockerfile
Last active March 14, 2019 16:12
Dockerfile for building MVIG-SJTU/AlphaPose
# based on [sberryman/Dockerfile.yml](https://gist.github.com/sberryman/82a6d13a44f9c4a3bfaf9263b36c92ed)
# You need the cuda drivers and [nvidia-docker](https://github.com/NVIDIA/nvidia-docker)
#
# build with
# docker build .
#
# run with
# docker run --runtime=nvidia -it --rm -v $(realpath ./data):/root/AlphaPose/data [imagename] ./run.sh --indir=/root/AlphaPose/data/in/ --outdir=data/out
FROM nvidia/cuda:8.0-cudnn5-devel
@cschell
cschell / sample.ipynb
Created April 29, 2018 09:19
Sample for `gp_minimize` result problem
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@cschell
cschell / last_game.rb
Last active February 11, 2019 19:19
This script queries the RIOT-API for the last game of a summoner
# Usage: ruby last_game.rb <summoner_name> <na/euw/...>
require "net/http"
require "json"
require "date"
# TODO: Insert your own key here!
API_KEY = "<YOUR-RIOT-API-KEY-HERE>"
@summoner_name = ARGV[0]
@cschell
cschell / delete_old_backups.sh
Created August 8, 2014 09:34
Delete backups that are x days old (from ftp server)
lftp -u <ftp_user>,<ftp_password> <ftp_host> -e "rm -rf `date --date="3 days ago" '+%Y-%m-%d_'`*; exit"
# make sure to escape % for cron:
lftp -u <ftp_user>,<ftp_password> <ftp_host> -e "rm -rf `date --date="3 days ago" '+\%Y-\%m-\%d_'`*; exit"
@cschell
cschell / postgres_ftp_backup.sh
Created August 8, 2014 09:31
Backup gziped postgresql dump to a ftp server
# shell command:
pg_dump <db_name> -U <db_user> -h <db_host> | gzip | curl -u <ftp_user>:<ftp_password> ftp://<ftp_host>/`date '+%Y-%m-%d_%H-%M'`/db_backup.sql.gz --ftp-create-dirs -T -
# if you want to execute it through cron, be sure to escape all %!
# for crontab:
pg_dump <db_name> -U <db_user> -h <db_host> | gzip | curl -u <ftp_user>:<ftp_password> ftp://<ftp_host>/`date '+\%Y-\%m-\%d_\%H-\%M'`/db_backup.sql.gz --ftp-create-dirs -T -
### Keybase proof
I hereby claim:
* I am cschell on github.
* I am cschell (https://keybase.io/cschell) on keybase.
* I have a public key whose fingerprint is D5A4 78EF 6166 5BAC A6D5 E6AC 4BED 524B 758B D750
To claim this, I am signing this object: