Skip to content

Instantly share code, notes, and snippets.

#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;
'''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
"""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 January 29, 2019 06:51
Python logging helper module
"""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))
"""
@batzner
batzner / tensorflow_rename_variables.py
Last active May 25, 2023 06:15
Small python script to rename variables in a TensorFlow checkpoint
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)