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 AtariNet(object): | |
# ... | |
# ... | |
def _build(self): | |
# ... | |
# ... | |
# convolutional layers for minimap features | |
self.minimap_conv1 = tf.layers.conv2d( | |
inputs=self.minimap_processed, | |
filters=16, |
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 AtariNet(object): | |
# ... | |
# ... | |
def _build(self): | |
# ... | |
# ... | |
# action function identifier policy | |
self.function_policy = tf.squeeze(tf.layers.dense( | |
inputs=self.state_representation, | |
units=NUM_ACTIONS, |
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 A2CAtari(base_agent.BaseAgent): | |
# ... | |
# ... | |
def _sample_action(self, | |
screen_features, | |
minimap_features, | |
flat_features, | |
available_actions): | |
"""Sample actions and arguments from policy output layers.""" | |
screen_features = np.expand_dims(screen_features, 0) |
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 A2CAtari(base_agent.BaseAgent): | |
# ... | |
# ... | |
def _get_batch(self, terminal): | |
# ... | |
# ... | |
# calculate discounted rewards | |
raw_rewards = list(self.reward_buffer) | |
if terminal: | |
value = 0 |
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 AtariNet(object): | |
# ... | |
# ... | |
def _build_optimization(self): | |
# ... | |
# ... | |
self.advantage = tf.subtract( | |
self.returns, | |
tf.squeeze(tf.stop_gradient(self.value_estimate)), | |
name="advantage") |
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 numpy as np | |
import pandas as pd | |
import pandas_datareader.data as web | |
import datetime | |
start = datetime.datetime(2012, 1, 1) | |
end = datetime.datetime(2019, 1, 1) | |
df = web.DataReader("TSLA", 'yahoo', start, end) |
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
df_lagged = df.copy() | |
trailing_window_size = 10 | |
for window in range(1, trailing_window_size + 1): | |
shifted = df.shift(window) | |
shifted.columns = [x + "_lag" + str(window) for x in df.columns] | |
df_lagged = pd.concat((df_lagged, shifted), axis=1) | |
df_lagged = df_lagged.dropna() | |
df_lagged.head() |
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 numpy as np | |
import tensorflow as tf | |
def dense(x, weights, bias, activation=tf.identity, **activation_kwargs): | |
"""Dense layer.""" | |
z = tf.matmul(x, weights) + bias | |
return activation(z, **activation_kwargs) | |
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 numpy as np | |
import tensorflow as tf | |
def dense(x, weights, bias, activation=tf.identity, **activation_kwargs): | |
"""Dense layer.""" | |
z = tf.matmul(x, weights) + bias | |
return activation(z, **activation_kwargs) | |
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 numpy as np | |
import tensorflow as tf | |
def dense(x, weights, bias, activation=tf.identity, **activation_kwargs): | |
"""Dense layer.""" | |
z = tf.matmul(x, weights) + bias | |
return activation(z, **activationn_kwargs) | |