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

fix bug for tf.concat api #22

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
4 changes: 2 additions & 2 deletions es_distributed/policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,10 @@ def _make_net(self, o):
aidx_na = bins(x, adim, len(acvals_k), 'out') # values in [0, k-1]
a = tf.gather_nd(
acvals_ak,
tf.concat(2, [
tf.concat([
tf.tile(np.arange(adim)[None, :, None], [tf.shape(aidx_na)[0], 1, 1]),
tf.expand_dims(aidx_na, -1)
]) # (n,a,2)
], 2) # (n,a,2)
) # (n,a)
elif ac_bin_mode == 'continuous':
a = U.dense(x, adim, 'out', U.normc_initializer(0.01))
Expand Down
8 changes: 4 additions & 4 deletions es_distributed/tf_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def max(x, axis=None, keepdims=False):
def min(x, axis=None, keepdims=False):
return tf.reduce_min(x, reduction_indices=None if axis is None else [axis], keep_dims = keepdims)
def concatenate(arrs, axis=0):
return tf.concat(axis, arrs)
return tf.concat(arrs, axis)
def argmax(x, axis=None):
return tf.argmax(x, dimension=axis)

Expand Down Expand Up @@ -179,8 +179,8 @@ def intprod(x):

def flatgrad(loss, var_list):
grads = tf.gradients(loss, var_list)
return tf.concat(0, [tf.reshape(grad, [numel(v)])
for (v, grad) in zip(var_list, grads)])
return tf.concat([tf.reshape(grad, [numel(v)])
for (v, grad) in zip(var_list, grads)], 0)

class SetFromFlat(object):
def __init__(self, var_list, dtype=tf.float32):
Expand All @@ -202,7 +202,7 @@ def __call__(self, theta):

class GetFlat(object):
def __init__(self, var_list):
self.op = tf.concat(0, [tf.reshape(v, [numel(v)]) for v in var_list])
self.op = tf.concat([tf.reshape(v, [numel(v)]) for v in var_list], 0)
def __call__(self):
return get_session().run(self.op)

Expand Down