y in.

Parameters

    

  * **devices** ( _iterable of CUDA IDs_ ) – CUDA devices for which to fork the RNG. CPU RNG state is always forked. By default,  ` fork_rng()  ` operates on all devices, but will emit a warning if your machine has a lot of devices, since this function will run very slowly in that case. If you explicitly specify devices, this warning will be suppressed 

  * **enabled** ( [ _bool_ ](https://docs.python.org/3/library/functions.html#bool "\(in Python v3.8\)") ) – if ` False  ` , the RNG is not forked. This is a convenience argument for easily disabling the context manager without having to delete it and unindent your Python code under it. 

` torch.random. ` ` get_rng_state ` (  )  [ [source]
](_modules/torch/random.html#get_rng_state) ¶

    

Returns the random number generator state as a  torch.ByteTensor  .

` torch.random. ` ` initial_seed ` (  )  [ [source]
](_modules/torch/random.html#initial_seed) ¶

    

Returns the initial seed for generating random numbers as a Python  long  .

` torch.random. ` ` manual_seed ` (  _seed_ )  [ [source]
](_modules/torch/random.html#manual_seed) ¶

    

Sets the seed for generating random numbers. Returns a  torch.Generator
object.

Parameters

    

**seed** ( [ _int_ ](https://docs.python.org/3/library/functions.html#int
"\(in Python v3.8\)") ) – The desired seed.

` torch.random. ` ` seed ` (  )  [ [source]
](_modules/torch/random.html#seed) ¶

    

Sets the seed for generating random numbers to a non-deterministic random
number. Returns a 64 bit number used to seed the RNG.

` torch.random. ` ` set_rng_state ` (  _new_state_ )  [ [source]
](_modules/torch/random.html#set_rng_state) ¶

    

Sets the random number generator state.

Parameters

    

**new_state** ( _torch.ByteTensor_ ) – The desired state

[ Next ![](_static/images/chevron-right-orange.svg) ](sparse.html
"torch.sparse") [ ![](_static/images/chevron-right-orange.svg) Previous
](rpc/distributed_autograd.html "Distributed Autograd Design")

* * *

© Copyright 2019, Torch Contributors.

Built with [ Sphinx ](http://sphinx-doc.org/) using a [ theme
](https://github.com/rtfd/sphinx_rtd_theme) provided by [ Read the Docs
](https://readthedocs.org) .

  * torch.random 

![](https://www.googleadservices.com/pagead/conversion/795629140/?label=txkmCPmdtosBENSssfsC&guid=ON&script=0)

##  Docs

Access comprehensive developer documentation for PyTorch

[ View Docs ](https://pytorch.org/docs/stable/index.html)

##  Tutorials

Get in-depth tutorials for beginners and advanced developers

[ View Tutorials ](https://pytorch.org/tutorials)

##  Resources

Find development resources and get your questions answered

[ View Resources ](https://pytorch.org/resources)

[ ](https://pytorch.org/)

  * [ PyTorch ](https://pytorch.org/)
  * [ Get Started ](https://pytorch.org/get-started)
  * [ Features ](https://pytorch.org/features)
  * [ Ecosystem ](https://pytorch.org/ecosystem)
  * [ Blog ](https://pytorch.org/blog/)
  * [ Contributing ](https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md)

  * [ Resources ](https://pytorch.org/resources)
  * [ Tutorials ](https://pytorch.org/tutorials)
  * [ Docs ](https://pytorch.org/docs/stable/index.html)
  * [ Discuss ](https://discuss.pytorch.org)
  * [ Github Issues ](https://github.com/pytorch/pytorch/issues)
  * [ Brand Guidelines ](https://pytorch.org/assets/brand-guidelines/PyTorch-Brand-Guidelines.pdf)

  * Stay Connected 
  * Email Address 

[ ](https://www.facebook.com/pytorch) [ ](https://twitter.com/pytorch) [
](https://www.youtube.com/pytorch)

To analyze traffic and optimize your experience, we serve cookies on this
site. By clicking or navigating, you agree to allow our usage of cookies. As
the current maintainers of this site, Facebook’s Cookies Policy applies. Learn
more, including about available controls: [ Cookies Policy
](https://www.facebook.com/policies/cookies/) .

![](_static/images/pytorch-x.svg)

[ ](https://pytorch.org/)

  * [ Get Start