forked from jittor/jittor
doc: set seed
This commit is contained in:
parent
7a253e4a4a
commit
3a5a78544f
|
@ -1044,6 +1044,13 @@ def randperm(n, dtype="int32"):
|
|||
return index.cast(dtype)
|
||||
|
||||
def set_global_seed(seed):
|
||||
''' Sets the seeds of the random number generators of Python, numpy and jittor,
|
||||
simultaneously.
|
||||
|
||||
.. note::
|
||||
Jittor also gurantees each worker of jittor.dataset.Dataset to hold a different seed,
|
||||
which is global_seed ^ worker_id ^ 1234.
|
||||
'''
|
||||
import random
|
||||
random.seed(seed)
|
||||
jt.set_seed(seed)
|
||||
|
|
|
@ -13,8 +13,21 @@ namespace jittor {
|
|||
typedef void (*set_seed_callback)(int);
|
||||
|
||||
void init();
|
||||
|
||||
/**
|
||||
Sets the seed of jittor random number generator. Also see @jittor.set_global_seed.
|
||||
|
||||
----------------
|
||||
|
||||
* [in] seed: a python number.
|
||||
|
||||
*/
|
||||
// @pyjt(set_seed, seed)
|
||||
void set_seed(int seed);
|
||||
|
||||
/**
|
||||
Returns the seed of jittor random number generator.
|
||||
*/
|
||||
// @pyjt(get_seed)
|
||||
int get_seed();
|
||||
|
||||
|
|
Loading…
Reference in New Issue