Skip to content

Instantly share code, notes, and snippets.

@FoConrad
FoConrad / mnist.py
Created April 16, 2018 13:56
Weight divergence between TF and MX when using Adam optimizer from same initial weights
import argparse
import numpy as np # Version 1.13.1
import tensorflow as tf # Version 1.4.1
import mxnet as mx # Version 1.1.0
from mxnet import gluon, nd, autograd
# From openai baselines common/tf_util
def dense(x, size, name, weight_init=None, bias=True):
w = tf.get_variable(name + "/w", [x.get_shape()[1], size], initializer=weight_init)
ret = tf.matmul(x, w)
@FoConrad
FoConrad / main.py
Created January 26, 2018 19:19
Train supervised and policy gradient image classifier
# Policy gradient borrowed from https://github.com/pytorch/examples/
import time
import argparse
import torch
import torchvision
import numpy as np
import torchvision.transforms as transforms
import torch.nn as nn