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

Allow mixing values with tensors in lists that specify the shape of a Tensor. #465

Closed
cesarsalgado opened this issue Dec 10, 2015 · 2 comments
Labels
type:feature Feature requests

Comments

@cesarsalgado
Copy link
Contributor

There are many methods that expect a list or a tensor specifying a shape as argument. It is often the case that I want to pass an argument such as shape=[t1, v2] where t1 is a tensor with shape = TensorShape([]) and v2 is a value. This is currently not possible in many (maybe all) methods.

My current work around is the following.
1- convert v2 to a tensor t2 with tf.convert_to_tensor
2- use t1 = tf.expand_dims(0, t1) and t2 = tf.expand_dims(0, t2) to add a dimension of size 1 to the tensors
3- pass the argument as shape=tf.concat(0, [t1, t2])

Am I missing a simpler way to accomplish that? Is it a good idea to add a feature that allows passing mixture of tensors and values inside a list as argument?

Edit: I just found out that the method tf.pack allows lists with tensors and values as argument. But the method tf.truncated_normal for instance, doesn't allow.
I also realized that I can use tf.pack to replace the steps (1,2,3) above. But it still would be nice if all methods had the same behaviour.

@girving
Copy link
Contributor

girving commented Dec 10, 2015

Agreed, I've wanted this too. There are some annoying obstacles, since in some places we automatically convert singleton tensors to lists and this feature would be backwards incompatible, but we've had some internal discussion about removing that magical (and fairly unidiomatic) list conversion. If we did that, we'd be able to add your automatic conversion, which would be great.

@mrry
Copy link
Contributor

mrry commented May 16, 2016

Closing this as a duplicate of #2328.

@mrry mrry closed this as completed May 16, 2016
@aselle aselle added type:feature Feature requests and removed enhancement labels Feb 9, 2017
darkbuck pushed a commit to darkbuck/tensorflow that referenced this issue Jan 23, 2020
…pstream-deven-remove-parens-dim3

removing the extra parens and "dim3" calls in the args to "GpuLaunchKernel".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature Feature requests
Projects
None yet
Development

No branches or pull requests

4 participants