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 tensorflow as tf | |
from preppy import BibPreppy | |
def expand(x): | |
''' | |
Hack. Because padded_batch doesn't play nice with scalres, so we expand the scalar to a vector of length 1 | |
:param x: | |
:return: |
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
if __name__=="__main__": | |
#make the iterators and next element op | |
next_element, training_init_op, validation_init_op = prepare_dataset_iterators(batch_size=32) | |
... | |
for epoch in range(1000): | |
#Initialize the iterator to consume training data | |
sess.run(training_init_op) | |
while True: | |
#As long as the iterator is not empty |
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 pandas as pd | |
D = pd.read_csv('./my_csv_file.csv') | |
D.to_json('./my_new_json_file.json',orient="records") |
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 pprint | |
import boto3 | |
import sys | |
repo_name = sys.argv[1] | |
print(repo_name) | |
client = boto3.client('ecr') | |
response = client.list_images( | |
repositoryName=repo_name, | |
filter={ | |
'tagStatus': 'TAGGED' |
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 | |
def make_stock(length=100, num_stocks=2): | |
alpha = 0.9 | |
k = 2 | |
cov = np.random.normal(0, 5, [num_stocks, num_stocks]) | |
cov = cov.dot(cov.T) # This is a positive semidefinite matrix, e.g. a covariance matrix | |
A = np.random.multivariate_normal(np.zeros(num_stocks), cov, size=[length]) # sample noise, with covariance | |
B = np.random.multivariate_normal(np.zeros(num_stocks), cov, size=[length]) # sample another noise, with covariance | |
bs = [np.zeros(shape=num_stocks)] # | |
ps = [np.zeros(shape=num_stocks)] # The prices |
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 collections import defaultdict | |
from env.priceGenerator import make_stock | |
costPerShare = 0 # 0.01 | |
class Env: | |
''' | |
A simple environemnt for our agent, | |
the action our agent gives is weighting over the stocks + cash |
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
self.alphas= tf.contrib.layers.fully_connected( | |
inputs=l2, | |
num_outputs=num_stocks+1, | |
activation_fn=tf.nn.relu, | |
weights_initializer=tf.initializers.glorot_uniform) | |
self.alphas +=1 | |
self.dirichlet = tfp.distributions.Dirichlet(self.alphas) | |
self.action = self.dirichlet._sample_n(1) |
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
sudo yum update -y | |
sudo yum install -y docker | |
sudo usermod -a -G docker ec2-user | |
sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null | |
sudo chmod +x /usr/local/bin/docker-compose | |
sudo service docker start | |
sudo chkconfig docker on | |
sudo systemctl enable docker |