Skip to content

Instantly share code, notes, and snippets.

@dariocazzani
Created May 8, 2018 19:43
Show Gist options
  • Select an option

  • Save dariocazzani/dca9b0966a250cda524fc6a2abfb00a5 to your computer and use it in GitHub Desktop.

Select an option

Save dariocazzani/dca9b0966a250cda524fc6a2abfb00a5 to your computer and use it in GitHub Desktop.
WorldModels-decide-VAE-action
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]
if prediction[1] < 0:
action[1] = np.abs(prediction[1])
action[2] = 0
else:
action[2] = prediction[1]
action[1] = 0
return action
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment