Created
May 8, 2018 19:43
-
-
Save dariocazzani/dca9b0966a250cda524fc6a2abfb00a5 to your computer and use it in GitHub Desktop.
WorldModels-decide-VAE-action
This file contains hidden or 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
| 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