This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Original implementation | |
https://github.com/clab/dynet_tutorial_examples/blob/master/tutorial_parser.ipynb | |
The code structure and variable names are similar for better reference. | |
Not for serious business, just for some comparison between PyTorch and DyNet | |
(and I still prefer PyTorch) | |
''' | |
import torch as T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as TF | |
import modeltf as model | |
import numpy as NP | |
import numpy.random as RNG | |
import h5py | |
import argparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Code to load an expert policy and generate roll-out data for behavioral cloning. | |
Example usage: | |
python run_expert.py experts/Humanoid-v1.pkl Humanoid-v1 --render \ | |
--num_rollouts 20 | |
Author of this script and included expert policies: Jonathan Ho ([email protected]) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Modified from example/autograd/{data,dcgan}.py to make it standalone. | |
import argparse | |
import mxnet as mx | |
from mxnet import nn | |
from mxnet.contrib import autograd | |
import numpy as np | |
import matplotlib.pyplot as PL | |
import time | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import mxnet as mx | |
from mxnet import nn | |
from mxnet.contrib import autograd | |
import numpy as np | |
import time | |
import os | |
ngpu = 1 | |
nz = 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch as T | |
import numpy as NP | |
### Norm of vector difference | |
# Checker | |
def normdiff_assert(X, Y, normdiff): | |
norm = normdiff(X, Y) | |
for i in range(X.size()[2]): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch as T | |
import numpy as np | |
x = T.autograd.Variable(T.randn(5, 8), requires_grad=True) | |
p = T.nn.functional.softmax(x) | |
y = p.multinomial() | |
y.reinforce(T.ones(y.size())) | |
y.backward() | |
d = x.grad.data.clone().numpy() | |
x.grad.data.zero_() | |
logp = T.nn.functional.log_softmax(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# References: | |
# https://arxiv.org/pdf/1405.5869.pdf | |
# https://arxiv.org/abs/1507.05910 | |
import numpy as np | |
from scipy.spatial.distance import cosine | |
# Rescaling and appending new components to "normalize" data vectors | |
X = np.random.randn(10000, 100) | |
Xn = np.sqrt((X ** 2).sum(1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unordered_map> | |
#include <map> | |
#include <vector> | |
#include <iostream> | |
#include <utility> | |
#include <cstdint> | |
#include <ctime> | |
#include <cstdlib> | |
using std::uint64_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
import time | |
N = 10000 | |
D = 50 | |
E = 500000 | |
T = 10 | |
t_gather = 0 | |
t_scatter = 0 |
OlderNewer