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
from gym.spaces import Discrete | |
import numpy as np | |
import ray | |
from ray.rllib.env.multi_agent_env import MultiAgentEnv | |
from ray.rllib.models import ModelCatalog | |
from ray.rllib.agents.ppo import ddppo | |
from ray.rllib.agents.ppo import DDPPOTrainer | |
from ray.rllib.utils.framework import try_import_tf |
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
# -*- coding: utf-8 -*- | |
"""mod_pol.ipynb | |
Automatically generated by Colaboratory. | |
Original file is located at | |
""" | |
""" | |
# Commented out IPython magic to ensure Python compatibility. |
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
# -*- coding: utf-8 -*- | |
"""hyp_chg_MARL.ipynb | |
Automatically generated by Colaboratory. | |
Original file is located at | |
""" | |
# Commented out IPython magic to ensure Python compatibility. | |
""" |
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
def kl_mvn(m0, S0, m1, S1): | |
""" | |
https://stackoverflow.com/questions/44549369/kullback-leibler-divergence-from-gaussian-pm-pv-to-gaussian-qm-qv | |
The following function computes the KL-Divergence between any two | |
multivariate normal distributions | |
(no need for the covariance matrices to be diagonal) | |
Kullback-Liebler divergence from Gaussian pm,pv to Gaussian qm,qv. | |
Also computes KL divergence from a single Gaussian pm,pv to a set |
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 numpy as np | |
latent_dim = 2 | |
#class FSRNNCell_VU(tf.contrib.rnn.RNNCell): | |
class FSRNNCell_VU(tf.compat.v1.nn.rnn_cell.RNNCell): | |
def __init__(self, fast_cells, slow_cell, input_keep_prob=1.0, keep_prob=1.0, training=True): |
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
#class FSRNNCell(tf.contrib.rnn.RNNCell): | |
class FSRNNCell(tf.compat.v1.nn.rnn_cell.RNNCell): | |
def __init__(self, fast_cells, slow_cell, input_keep_prob=1.0, keep_prob=1.0, training=True): | |
"""Initialize the basic Fast-Slow RNN. | |
Args: | |
fast_cells: A list of RNN cells that will be used for the fast RNN. | |
The cells must be callable, implement zero_state() and all have the | |
same hidden size, like for example tf.contrib.rnn.BasicLSTMCell. | |
slow_cell: A single RNN cell for the slow RNN. | |
keep_prob: Keep probability for the non recurrent dropout. Any kind of |
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 numpy as np | |
m1 = np.array([[[0.0], [1.1]], [[0.1], [1.2]], [[0.2], [1.3]]]) | |
s1 = np.array([[[1.1]], [[1.2]], [[1.3]]]) | |
m2 = np.array([[[1.0]], [[1.1]], [[1.2]]]) | |
s2 = np.array([[[0.1]], [[0.2]], [[0.3]]]) | |
print(m1.shape) | |
nd_1 = tf.distributions.Normal(loc=m1, scale=s1) |
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/python | |
from __future__ import print_function | |
from random import * | |
import sys | |
sys.path.append('..') | |
from orderbook import OrderBook | |
order_book = OrderBook() | |
order_0 = {'type' : 'limit', |
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
Creating tmp8z_8haic_algo-1-vmd10_1 ... | |
Attaching to tmp8z_8haic_algo-1-vmd10_12mdone | |
algo-1-vmd10_1 | 2019-09-30 07:54:22,885 sagemaker-containers INFO Imported framework sagemaker_tensorflow_container.training | |
algo-1-vmd10_1 | 2019-09-30 07:54:22,892 sagemaker-containers INFO No GPUs detected (normal if no gpus installed) | |
algo-1-vmd10_1 | 2019-09-30 07:54:23,011 sagemaker-containers INFO No GPUs detected (normal if no gpus installed) | |
algo-1-vmd10_1 | 2019-09-30 07:54:23,031 sagemaker-containers INFO No GPUs detected (normal if no gpus installed) | |
algo-1-vmd10_1 | 2019-09-30 07:54:23,045 sagemaker-containers INFO Invoking user script | |
algo-1-vmd10_1 | | |
algo-1-vmd10_1 | Training Env: | |
algo-1-vmd10_1 | |