Skip to content

Instantly share code, notes, and snippets.

import pickle
import tensorflow as tf
class TestModule(tf.Module):
def __init__(self, model):
self.model = model
import pickle
import tensorflow as tf
def main():
model_1 = tf.keras.Sequential((
tf.keras.layers.Dense(16, activation='relu'),
tf.keras.layers.Dense(1, activation='linear'),
))
import pickle
import tensorflow as tf
def main():
x = tf.keras.layers.Input((3, ))
y = tf.keras.layers.Dense(5)(x)
model_1 = tf.keras.Model(x, y)
from timeit import time
import tensorflow as tf
def test_fake_data():
matrices = [
tf.random.uniform((6, 6), -1.0, 1.0)
for i in range(4)
]
import tensorflow as tf
batch_size = 32
data = tf.random.uniform((1024, 4))
model = tf.keras.Sequential((
tf.keras.layers.Dense(32, activation='relu'),
tf.keras.layers.Dense(2, activation='linear'),
))
import tensorflow as tf
import tensorflow_probability as tfp
def main():
x = tf.Variable(0.5)
y = tfp.util.DeferredTensor(x, tf.exp)
print(y.numpy()) # y.transform_fn(y.variables).numpy() works.
import random
import time
import tensorflow as tf
from ray import tune
from wandb.ray import WandbLogger
class ExperimentRunner(tune.Trainable):
def _setup(self, variant):
import random
import time
import tensorflow as tf
from ray import tune
from wandb.ray import WandbLogger
class MyLogger(tune.logger.Logger):
def _init(self):
#!/bin/bash
pid=$1
me="$(basename $0)($$):"
if [ -z "$pid" ]
then
echo "${me} a PID is required as an argument" >&2
exit 2
fi
@hartikainen
hartikainen / animate_distances.py
Created July 22, 2019 04:57
Distance website figures
import numpy as np
import matplotlib
matplotlib.use('TKAgg')
from matplotlib import pyplot as plt
from matplotlib import animation
from .data import WALLS, TRAJECTORIES
# First set up the figure, the axis, and the plot element we want to animate