Skip to content

Instantly share code, notes, and snippets.

@hartikainen
hartikainen / csv-to-arrow-table.js
Last active November 22, 2024 03:48
Create an arrow-js table from csv file using node streams
const assert = require('assert');
const fs = require('fs');
const stream = require('stream');
const _ = require('lodash');
const fastCsv = require('fast-csv');
const { metrohash64 } = require('metrohash');
const {
Bool, Utf8, Int32, Int64, Float32, Float64, Struct, Dictionary,
@hartikainen
hartikainen / main.py
Last active March 28, 2020 23:36
Policy evaluation with bilevel optimization
import argparse
import datetime
import itertools
import os
import numpy as np
import ray
from ray import tune
import tensorflow as tf
import tree
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from experiments import load_results
TASKS = [
@hartikainen
hartikainen / apply-patch.sh
Last active March 13, 2020 10:43
Saves the diff between index and working copy
# NOTE(hartikainen): Might want to check that the working tree is clean.
commit_sha="$(cat ./name_rev.txt | awk -F' ' '{print $1}')"
git checkout "${commit_sha}"
echo "Applying patch: $(cat ./patch.diff)"
git apply patch.diff
import random
import time
import tensorflow as tf
from ray import tune
class ExperimentRunner(tune.Trainable):
def _setup(self, variant):
self.timestep = 0
import tensorflow as tf
class TestModule(tf.Module):
def __init__(self, value):
self.variable = tf.Variable(value)
module_1 = TestModule(value=9000)
tf.saved_model.save(module_1, "./foo")
import tensorflow as tf
import tensorflow_probability as tfp
from softlearning.utils.tensorflow import nest
@tf.function(experimental_relax_shapes=True)
def another_test_function(inputs):
outputs = {'old': inputs, 'new': inputs + 100}
return outputs
import gym
import tensorflow as tf
from sklearn import preprocessing
from softlearning.utils.tensorflow import cast_and_concat
feature_fn = preprocessing.PolynomialFeatures(2)
import tensorflow as tf
class TestModule(tf.Module):
def __init__(self, model):
self.model = model
x = tf.keras.layers.Input((3, ))
y = tf.keras.layers.Dense(5)(x)
import tensorflow as tf
class TestModule(tf.Module):
def __init__(self, value, model):
self.value = value
self.model = model
def main():