This file contains hidden or 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 glob | |
import os | |
from pprint import pprint | |
import re | |
import shutil | |
RESULT_FILE_REGEXES = ( | |
"^result.json$", | |
"^progress.csv$", |
This file contains hidden or 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 os | |
import sys | |
from shutil import copyfile | |
import numpy as np | |
import pandas as pd | |
def get_result_path(trial_dir): | |
return os.path.join(trial_dir, "progress.csv") |
This file contains hidden or 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
from collections import defaultdict | |
import time | |
import matplotlib.pyplot as plt | |
import numpy as np | |
def create_fields(observation_shape, action_shape): | |
fields = { | |
'observations': observation_shape, |
This file contains hidden or 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 tempfile | |
import tensorflow as tf | |
class PicklableKerasModel(tf.keras.Model): | |
def __getstate__(self): | |
with tempfile.NamedTemporaryFile(suffix='.hdf5', delete=True) as fd: | |
tf.keras.models.save_model(self, fd.name, overwrite=True) | |
model_str = fd.read() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 numpy as np | |
import tensorflow as tf | |
import tensorflow_probability as tfp | |
class LearnableConditionalRealNVP(object): | |
def __init__(self, input_shape, output_shape): | |
self._input_shape = input_shape | |
self._output_size = np.prod(output_shape) |
This file contains hidden or 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
class FloatLookupLayer(tf.keras.layers.Layer): | |
def __init__(self, all_observation_pairs, **kwargs): | |
self.all_observation_pairs = all_observation_pairs | |
x = np.reshape( | |
self.all_observation_pairs, | |
(self.all_observation_pairs.shape[0], | |
np.prod(self.all_observation_pairs.shape[1:3]))) | |
x = tf.reduce_join(tf.as_string(x), separator='|', axis=-1) | |
x = tf.concat((x, ['ERROR']), axis=0) |
This file contains hidden or 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
# Base softlearning container that contains all softlearning requirements, | |
# but not the actual softlearning repo. Could be used for example when developing | |
# softlearning, in which case you would mount softlearning repo in to the container | |
# as a volume, and thus be able to modify code on the host, yet run things inside | |
# the container. You are encouraged to use docker-compose (docker-compose.dev.yml), | |
# which should allow you to setup your environment with a single one command. | |
FROM nvidia/cuda:9.0-runtime-ubuntu16.04 | |
ARG MJKEY |
This file contains hidden or 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 numpy as np | |
from sklearn.model_selection import train_test_split | |
def split_data(X, y, train_prop, val_prop, test_prop, N_dev=0, verbose=True): | |
""" Split the dataset (X, y) into train, validation, and test sets. | |
Also, possibly create a small dataset for development purposes. Note that | |
the proportions should sum to 1. | |
Arguments: | |
X -- Feature matrix, shape of (N, D_in) |
NewerOlder