Skip to content

Instantly share code, notes, and snippets.

def build_model():
"""
"""
initializer = tf.truncated_normal_initializer(stddev=0.02)
feature_size = len(FLAGS.features)
source = \
tf.placeholder(shape=[None, 32, 28 * feature_size], dtype=tf.float32)
target = \
def instance_norm(flow):
"""
arXiv:1607.08022v2
"""
with tf.variable_scope('inst_norm'):
depth = flow.get_shape()[3]
scale = tf.get_variable(
'scale',
[depth],
initializer=tf.random_normal_initializer(1.0, 0.02))
def build_model():
"""
"""
eigens = tf.placeholder(shape=[None, 32, 28, 1], dtype=tf.float32)
labels = tf.placeholder(shape=[None, 28], dtype=tf.float32)
flow = eigens
weights_initializer = tf.truncated_normal_initializer(stddev=0.02)
@imironhead
imironhead / kktv_datagame_1711_linear_modelmodel.py
Last active December 10, 2017 05:06
code to get best weights for linear regression
def linear():
"""
"""
eigens = np.load('../dataset/v0_eigens.npz')
train_eigens = eigens['train_eigens']
issue_eigens = eigens['issue_eigens']
# 28 boolean a week, labels are the last week
# train = training, issue = testing, eigens = features
@imironhead
imironhead / kktv_datagame_1711_linear_walker.py
Last active December 8, 2017 10:27
code to search linear combination weights
# there are 32 weeks
weights_center = 0.5 * np.ones((32, 1))
weights_offset = np.zeros_like(weights_center)
auc_save = 0.8
auc_best = 0.0
for step in range(steps):
# update weights
weights = np.clip(weights_center + weights_offset, 0.0, 1.0)
// algorithm
template <class InputIterator, class UnaryPredicate>
bool all_of (InputIterator first, InputIterator last, UnaryPredicate pred);
template <class InputIterator, class UnaryPredicate>
bool any_of (InputIterator first, InputIterator last, UnaryPredicate pred);
template <class InputIterator, class UnaryPredicate>
bool none_of (InputIterator first, InputIterator last, UnaryPredicate pred);
"""
Solve OpenAI Gym Cartpole V1 with DQN.
"""
import gym
import numpy as np
import tensorflow as tf
class DeepQLearningAgent(object):
@imironhead
imironhead / openai_cartpole_v0_dqn_2.py
Created September 7, 2016 16:19
improved version of openai_cartpole_v0_dqn.py
"""
Solve OpenAI Gym Cartpole V0 with DQN.
"""
import gym
import numpy as np
import tensorflow as tf
class DeepQLearningAgent(object):
@imironhead
imironhead / openai_cartpole_v0_dqn.py
Last active September 8, 2016 07:45
ironhead-cartpole-v0-dqn
"""
Solve OpenAI Gym Cartpole V0 with DQN.
"""
import gym
import numpy as np
import tensorflow as tf
class DeepQLearningAgent(object):