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
func Sort(v []uint32) { | |
rec0 := func(L, R int) { | |
l := L | |
r := R | |
for l <= r { | |
if v[l]&(1<<0) == 0 { | |
l++ | |
} else { | |
v[l], v[r] = v[r], v[l] | |
r-- |
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
state = get_first_state() | |
while not done: | |
# policy | |
if random ∈[0,1] < epsilon: action = random_action | |
else: action = argmax(nn.predict(state)) | |
next_state, reward, done = step(action) # perform the action | |
replay_memory.put(state, action, reward, done, next_state) # save in replay memory | |
if len(replay_memory) >= batch_size: # if there is enough memory | |
# get a mini-batch from the replay memory | |
for state_exp, action_exp, reward_exp, done_exp, next_state_exp in replay_memory.get_random(batch_size): |
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 gym | |
env = gym.make('CartPole-v1') | |
# initialize metrics | |
total_reward = 0 | |
steps = 0 | |
current_state = env.reset() # obtain first state | |
done = False | |
while not done: # when done is True the episode ends | |
action = env.action_space.sample() # get a random action from A of the environment | |
next_state, reward, done, _ = env.step(action) # perform the action |
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
func slowestKey(keyTimes [][]int32) string { | |
a := [][]int32{{-1, 0}} | |
keyTimes = append(a, keyTimes...) | |
var max int32 | |
var c int32 | |
for i := 1; i < len(keyTimes); i++ { | |
if tmp := keyTimes[i][1] - keyTimes[i-1][1]; tmp > max{ | |
max = tmp | |
c = keyTimes[i][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
https://github.com/AdicherlaVenkataSai/ml-workspace | |
https://github.com/sdmg15/Best-websites-a-programmer-should-visit | |
https://medium.com/ | |
https://www.000webhost.com/ | |
http://www.dot.tk/en/index.html?lang=en | |
https://web.archive.org/ | |
https://stackexchange.com/sites | |
https://kaitai.io/ | |
https://towardsdatascience.com/ |