Skip to content

Instantly share code, notes, and snippets.

View kengz's full-sized avatar

Wah Loon Keng kengz

View GitHub Profile
@kengz
kengz / Atom Highlighter HEX colors
Created June 26, 2015 19:07
Atom Highlighter colors
The HEX color for Atom highlighter theme: close to Base16 but lighter.
bgdark: #2b303b
red: #e26a78
cyan: #78dbf9
green: #8bdb97
purple: #d59cf6
orange: #dbad83
@kengz
kengz / NodeJS installation on Google Compute Engine
Last active August 29, 2015 14:24
NodeJS installation on Google Compute Engine
# First create a Google Compute Engine (GCE) VM instance, then SSH into the VM.
# 1. update everything
sudo apt-get update
# 2. install these 4 things
sudo apt-get install python g++ make checkinstall
# 3. make a src directory and go into it
mkdir ~/src && cd $_
@kengz
kengz / Deploying NodeJS App on Google Cloud Platform
Last active December 8, 2019 18:56
Deploying NodeJS App on Google Cloud Platform
# Deploying NodeJS App on Google Cloud Platform
`authored Jul 3 2015 by kengz`
## Installation
- Account with Google Cloud Platform.
- Install [Google Cloud Platform SDK](https://cloud.google.com/sdk/) to use `cloud` in the terminal.
- Install [Docker](https://cloud.google.com/tutorials/install-docker) for the VM container.
- Locally, login for the first time: `gcloud auth login`
@kengz
kengz / Global Hackers Missions
Last active August 29, 2015 14:25
Global Hackers
Global Hackers Missions
[ Feel free to contribute and sign your own contribution! Separate by “Insert > Horizontal line”. See example below. ]
[ Anyone can edit this document, so be responsible. Of course we back this up somewhere else too
###
This page is for doers who dare to, and for builders who want to, make a dent in the universe.
Do's: Be open minded, be dare, believe.
Don’t be butt-hurt, don’t be evil.

Keybase proof

I hereby claim:

  • I am kengz on github.
  • I am kengz (https://keybase.io/kengz) on keybase.
  • I have a public key ASCZnM1pXJ3J3XW9-Nk2h22qWrep6ra1BfxuN6YBZFTbggo

To claim this, I am signing this object:

def post_body_init(self):
'''Initializes the part of algorithm needing a body to exist first.'''
self.body = self.agent.nanflat_body_a[0] # single-body algo
# create the extra replay memory for SIL
memory_name = self.memory_spec['sil_replay_name']
MemoryClass = getattr(memory, memory_name)
self.body.replay_memory = MemoryClass(self.memory_spec, self, self.body)
self.init_algorithm_params()
self.init_nets()
logger.info(util.self_desc(self))
def train_shared(self):
'''
Trains the network when the actor and critic share parameters
'''
if self.to_train == 1:
# onpolicy a2c update
a2c_loss = super(SIL, self).train_shared()
# offpolicy sil update with random minibatch
total_sil_loss = torch.tensor(0.0)
for _ in range(self.training_epoch):
@kengz
kengz / sil_loss.py
Last active February 18, 2019 23:50
def calc_sil_policy_val_loss(self, batch):
'''
Calculate the SIL policy losses for actor and critic
sil_policy_loss = -log_prob * max(R - v_pred, 0)
sil_val_loss = norm(max(R - v_pred, 0)) / 2
This is called on a randomly-sample batch from experience replay
'''
returns = math_util.calc_returns(batch, self.gamma)
v_preds = self.calc_v(batch['states'])
clipped_advs = torch.clamp(returns - v_preds, min=0.0)
@kengz
kengz / slm-lab-installation.md
Last active December 11, 2020 02:56
SLM Lab quick installation
# init singleton agent and env
self.env = make_env(self.spec)
body = Body(self.env, self.spec['agent'])
self.agent = Agent(self.spec, self.info_space, body=body)