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

alias to generate tensor with random uniform distribution. #67321

Open
nitaifingerhut opened this issue Oct 27, 2021 · 7 comments · May be fixed by #68280
Open

alias to generate tensor with random uniform distribution. #67321

nitaifingerhut opened this issue Oct 27, 2021 · 7 comments · May be fixed by #68280

Comments

@nitaifingerhut
Copy link

@nitaifingerhut nitaifingerhut commented Oct 27, 2021

🚀 Feature

alias to generate tensor with random uniform distribution.

Motivation

uniform distribution is one of the most commonly used distributions by users. currently generating tensor distributed uniformly can be done using tensor initializer (torch.FloatTensor(*size).uniform_(low, high)), or by definition:
(high - low) * torch.rand(*size) + low.

Pitch

Adding the alias `torch.random.uniform(low, high, size) for initiating a uniformly distributed tensor.

Alternatives

described above.

cc @pbelevich

@nitaifingerhut nitaifingerhut changed the title generate tensor with random uniform distribution. alias to generate tensor with random uniform distribution. Oct 27, 2021
@anjali411
Copy link
Contributor

@anjali411 anjali411 commented Nov 10, 2021

SGTM!

@yatendra1999
Copy link

@yatendra1999 yatendra1999 commented Nov 11, 2021

I am new to the codebase and would like to work on this but I have some questions.
torch.random contains functions for RNG like seed and such. Is this the right package to add this in?
Would simply adding a function calling the other functions be the correct way of adding an alias?
@albanD @nitaifingerhut @anjali411

@nitaifingerhut
Copy link
Author

@nitaifingerhut nitaifingerhut commented Nov 11, 2021

from my point of view it seems correct. You can simply add  1�7(high - low) * torch.rand(*size) + low 1�7 to torch.random @anjali411 @albanD @yatendra1999

@saik2121
Copy link

@saik2121 saik2121 commented Nov 22, 2021

def uniform(low,high,size):
return (low-high)*torch.randn(size)+high.

this will work I guess.

@mrinmoy2000
Copy link

@mrinmoy2000 mrinmoy2000 commented Dec 3, 2021

Is this issue still open?

@ParulSrivastava
Copy link

@ParulSrivastava ParulSrivastava commented Dec 5, 2021

tf.random.Generator(
copy_from=None, state=None, alg=None
)

@nitaifingerhut
Copy link
Author

@nitaifingerhut nitaifingerhut commented Dec 5, 2021

I guess we are still waiting to see if the FR was accepted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

7 participants