Skip to content

Instantly share code, notes, and snippets.

Avatar

Kilian Batzner batzner

View GitHub Profile
View show_large_emails.py
"""Lists all e-mails for a given IMAP account, largest first. Can be useful when freeing up space.
Requires imapclient==2.1.0 and python3.6 or higher.
"""
from collections import namedtuple
from email.header import decode_header
from imapclient import IMAPClient
@batzner
batzner / log.py
Created Jan 29, 2019
Python logging helper module
View log.py
"""Helper module for logging.
Example Usage:
from log import get_logger, get_out_dir_of_logger
LOG = get_logger(__name__)
LOG.info('Logging to %s' % get_out_dir_of_logger(LOG))
"""
View dropout_reuse_masks.py
'''Trains a simple convnet on the MNIST dataset with adversarial training.
During the adversarial train step's feed-forward pass, the dropout masks can be
reused by setting REUSE_DROPOUT to True
For more info, see https://stackoverflow.com/questions/53395329/should-dropout-masks-be-reused-during-adversarial-training
Requirements:
- tensorflow==1.12.0
- cleverhans bleeding edge: pip install git+https://github.com/tensorflow/cleverhans.git#egg=cleverhans
View santa_gift_matching.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef int bool;
#define true 1
#define false 0
const unsigned int N_CHILDREN = 1000000;
const unsigned int N_GIFT_PREF = 10;
@batzner
batzner / tensorflow_rename_variables.py
Last active Jul 22, 2020
Small python script to rename variables in a TensorFlow checkpoint
View tensorflow_rename_variables.py
import sys, getopt
import tensorflow as tf
usage_str = 'python tensorflow_rename_variables.py --checkpoint_dir=path/to/dir/ ' \
'--replace_from=substr --replace_to=substr --add_prefix=abc --dry_run'
def rename(checkpoint_dir, replace_from, replace_to, add_prefix, dry_run):
checkpoint = tf.train.get_checkpoint_state(checkpoint_dir)
You can’t perform that action at this time.