Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed up the policy optimization by @tf.function #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pilco/models/pilco.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def optimize_policy(self, maxiter=50, restarts=1):
def compute_action(self, x_m):
return self.controller.compute_action(x_m, tf.zeros([self.state_dim, self.state_dim], float_type))[0]

@tf.function
def predict(self, m_x, s_x, n):
loop_vars = [
tf.constant(0, tf.int32),
Expand Down
1 change: 1 addition & 0 deletions pilco/rewards.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def __init__(self, state_dim, W=None, t=None):
else:
self.t = Parameter(np.zeros((1, state_dim)), trainable=False)

@tf.function
def compute_reward(self, m, s):
'''
Reward function, calculating mean and variance of rewards, given
Expand Down