Skip to content

Commit 57b04ee

Browse files
MorvanZhouMorvan Zhou
authored andcommitted
update to tf r1.3
1 parent 5e76b69 commit 57b04ee

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

contents/10_A3C/A3C_RNN.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
View more on my tutorial page: https://morvanzhou.github.io/tutorials/
77
88
Using:
9-
tensorflow 1.0
9+
tensorflow r1.3
1010
gym 0.8.0
1111
"""
1212

@@ -63,7 +63,7 @@ def __init__(self, scope, globalAC=None):
6363
with tf.name_scope('wrap_a_out'):
6464
mu, sigma = mu * A_BOUND[1], sigma + 1e-4
6565

66-
normal_dist = tf.contrib.distributions.Normal(mu, sigma)
66+
normal_dist = tf.distributions.Normal(mu, sigma)
6767

6868
with tf.name_scope('a_loss'):
6969
log_prob = normal_dist.log_prob(self.a_his)

contents/10_A3C/A3C_continuous_action.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
View more on my tutorial page: https://morvanzhou.github.io/tutorials/
77
88
Using:
9-
tensorflow 1.0
9+
tensorflow r1.3
1010
gym 0.8.0
1111
"""
1212

@@ -63,7 +63,7 @@ def __init__(self, scope, globalAC=None):
6363
with tf.name_scope('wrap_a_out'):
6464
mu, sigma = mu * A_BOUND[1], sigma + 1e-4
6565

66-
normal_dist = tf.contrib.distributions.Normal(mu, sigma)
66+
normal_dist = tf.distributions.Normal(mu, sigma)
6767

6868
with tf.name_scope('a_loss'):
6969
log_prob = normal_dist.log_prob(self.a_his)

contents/12_Proximal_Policy_Optimization/DPPO.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
View more on my tutorial website: https://morvanzhou.github.io/tutorials
1111
1212
Dependencies:
13-
tensorflow r1.2
13+
tensorflow r1.3
1414
gym 0.9.2
1515
"""
1616

1717
import tensorflow as tf
18-
from tensorflow.contrib.distributions import Normal
1918
import numpy as np
2019
import matplotlib.pyplot as plt
2120
import gym, threading, queue
@@ -87,7 +86,7 @@ def _build_anet(self, name, trainable):
8786
l1 = tf.layers.dense(self.tfs, 200, tf.nn.relu, trainable=trainable)
8887
mu = 2 * tf.layers.dense(l1, A_DIM, tf.nn.tanh, trainable=trainable)
8988
sigma = tf.layers.dense(l1, A_DIM, tf.nn.softplus, trainable=trainable)
90-
norm_dist = Normal(loc=mu, scale=sigma)
89+
norm_dist = tf.distributions.Normal(loc=mu, scale=sigma)
9190
params = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope=name)
9291
return norm_dist, params
9392

contents/12_Proximal_Policy_Optimization/simply_PPO.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"""
1414

1515
import tensorflow as tf
16-
from tensorflow.contrib.distributions import Normal, kl_divergence
1716
import numpy as np
1817
import matplotlib.pyplot as plt
1918
import gym
@@ -65,7 +64,7 @@ def __init__(self):
6564
surr = ratio * self.tfadv
6665
if METHOD['name'] == 'kl_pen':
6766
self.tflam = tf.placeholder(tf.float32, None, 'lambda')
68-
kl = tf.stop_gradient(kl_divergence(oldpi, pi))
67+
kl = tf.stop_gradient(tf.distributions.kl_divergence(oldpi, pi))
6968
self.kl_mean = tf.reduce_mean(kl)
7069
self.aloss = -(tf.reduce_mean(surr - self.tflam * kl))
7170
else: # clipping method, find this is better
@@ -109,7 +108,7 @@ def _build_anet(self, name, trainable):
109108
l1 = tf.layers.dense(self.tfs, 100, tf.nn.relu, trainable=trainable)
110109
mu = 2 * tf.layers.dense(l1, A_DIM, tf.nn.tanh, trainable=trainable)
111110
sigma = tf.layers.dense(l1, A_DIM, tf.nn.softplus, trainable=trainable)
112-
norm_dist = Normal(loc=mu, scale=sigma)
111+
norm_dist = tf.distributions.Normal(loc=mu, scale=sigma)
113112
params = tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope=name)
114113
return norm_dist, params
115114

contents/8_Actor_Critic_Advantage/AC_continue_Pendulum.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
View more on my tutorial page: https://morvanzhou.github.io/tutorials/
99
1010
Using:
11-
tensorflow 1.0
11+
tensorflow r1.3
1212
gym 0.8.0
1313
"""
1414

@@ -57,7 +57,7 @@ def __init__(self, sess, n_features, action_bound, lr=0.0001):
5757
global_step = tf.Variable(0, trainable=False)
5858
# self.e = epsilon = tf.train.exponential_decay(2., global_step, 1000, 0.9)
5959
self.mu, self.sigma = tf.squeeze(mu*2), tf.squeeze(sigma+0.1)
60-
self.normal_dist = tf.contrib.distributions.Normal(self.mu, self.sigma)
60+
self.normal_dist = tf.distributions.Normal(self.mu, self.sigma)
6161

6262
self.action = tf.clip_by_value(self.normal_dist.sample(1), action_bound[0], action_bound[1])
6363

0 commit comments

Comments
 (0)