http://ubuntuhandbook.org/index.php/2017/01/install-wine-2-0-ubuntu-16-04-14-04-16-10/
curl -o ~/Downloads/SteamSetup.exe http://media.steampowered.com/client/installer/SteamSetup.exe
import numpy as np | |
import random | |
from termcolor import colored | |
""" | |
https://www.slickcharts.com/sp500/returns | |
""" | |
SP500_history = list(reversed([-4.38, 21.83, 11.96, 1.38, 13.69, 32.39, 16, 2.11, 15.06, 26.46, -37, 5.49, 15.79, 4.91, 10.88, 28.68, -22.1, -11.89, -9.1, 21.04, 28.58, 33.36, 22.96, 37.58, 1.32, 10.08, 7.62, 30.47, -3.1, 31.69, 16.61, 5.25, 18.67, 31.73, 6.27, 22.56, 21.55, -4.91, 32.42, 18.44, 6.56, -7.18, 23.84, 37.2, -26.47, -14.66, 18.98, 14.31, 4.01, -8.5, 11.06, 23.98, -10.06, 12.45, 16.48, 22.8, -8.73, 26.89, 0.47, 11.96, 43.36, -10.78, 6.56, 31.56, 52.62, -0.99, 18.37, 24.02, 31.71, 18.79, 5.5, 5.71, -8.07, 36.44, 19.75, 25.9, 20.34, -11.59, -9.78, -0.41, 31.12, -35.03, 33.92, 47.67, -1.44, 53.99, -8.19, -43.34, -24.9, -8.42, 43.61, 37.49, 11.62])) | |
initial_withdraw = 1. | |
increase = 1 |
from gym.envs.box2d.car_dynamics import Car | |
from gym.envs.box2d import CarRacing | |
[...] | |
position = np.random.randint(len(env.track)) | |
env.car = Car(env.world, *env.track[position][1:4]) |
with mp.Pool(mp.cpu_count()) as p: | |
p.map(simulate_batch, range(_NUM_BATCHES)) |
def train(): | |
es = cma.CMAEvolutionStrategy(_NUM_PARAMS * [0], 0.1, {'popsize': 16}) | |
rewards_through_gens = [] | |
generation = 1 | |
try: | |
while not es.stop(): | |
solutions = es.ask() | |
with mp.Pool(mp.cpu_count()) as p: | |
rewards = list(tqdm.tqdm(p.imap(play, list(solutions)), total=len(solutions))) |
def decide_action(sess, network, observation, params): | |
observation = normalize_observation(observation) | |
embedding = sess.run(network.z, feed_dict={network.image: observation[None, :, :, :]}) | |
weights, bias = get_weights_bias(params) | |
action = np.zeros(_NUM_ACTIONS) | |
prediction = np.matmul(np.squeeze(embedding), weights) + bias | |
prediction = np.tanh(prediction) | |
action[0] = prediction[0] |
class Network(object): | |
# Create model | |
def __init__(self): | |
self.image = tf.placeholder(tf.float32, [None, 96, 96, 3], name='image') | |
self.resized_image = tf.image.resize_images(self.image, [64, 64]) | |
tf.summary.image('resized_image', self.resized_image, 20) | |
self.z_mu, self.z_logvar = self.encoder(self.resized_image) | |
self.z = self.sample_z(self.z_mu, self.z_logvar) | |
self.reconstructions = self.decoder(self.z) |
from __future__ import division | |
import numpy as np | |
import pandas as pd | |
import copy | |
from Engine import Engine | |
import matplotlib.pyplot as plt | |
from sklearn import datasets | |
from sklearn.model_selection import train_test_split |
from __future__ import division | |
import numpy as np | |
import sys | |
from operator import methodcaller | |
from Engine import Engine | |
# data from https://people.sc.fsu.edu/~jburkardt/datasets/knapsack_01/knapsack_01.html | |
capacity = 6404180 | |
weights = [382745, 799601, 909247, 729069, 467902, 44328, 34610, 698150, 823460,\ |
def run(self): | |
now = time.time() | |
try: | |
for i in range(self.iterations): | |
self.__produce_next_gen() | |
self.__mutation() | |
except KeyboardInterrupt: | |
print('Quitting...') | |
run_time = time.time() - now | |
print('Run time: {:.2f}'.format(run_time)) |