Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
pytorch-doc-zh
提交
a363d0aa
P
pytorch-doc-zh
项目概览
OpenDocCN
/
pytorch-doc-zh
通知
121
Star
3932
Fork
992
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pytorch-doc-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a363d0aa
编写于
2月 05, 2024
作者:
绝不原创的飞龙
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
2024-02-05 13:58:25
上级
08918adb
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
3696 addition
and
26 deletion
+3696
-26
totrans/doc22_072.yaml
totrans/doc22_072.yaml
+376
-0
totrans/doc22_073.yaml
totrans/doc22_073.yaml
+223
-0
totrans/doc22_074.yaml
totrans/doc22_074.yaml
+575
-6
totrans/doc22_075.yaml
totrans/doc22_075.yaml
+800
-0
totrans/doc22_076.yaml
totrans/doc22_076.yaml
+70
-0
totrans/doc22_077.yaml
totrans/doc22_077.yaml
+523
-12
totrans/doc22_078.yaml
totrans/doc22_078.yaml
+252
-0
totrans/doc22_079.yaml
totrans/doc22_079.yaml
+877
-8
未找到文件。
totrans/doc22_072.yaml
浏览文件 @
a363d0aa
此差异已折叠。
点击以展开。
totrans/doc22_073.yaml
浏览文件 @
a363d0aa
此差异已折叠。
点击以展开。
totrans/doc22_074.yaml
浏览文件 @
a363d0aa
此差异已折叠。
点击以展开。
totrans/doc22_075.yaml
浏览文件 @
a363d0aa
此差异已折叠。
点击以展开。
totrans/doc22_076.yaml
浏览文件 @
a363d0aa
-
en
:
torch.random
id
:
totrans-0
prefs
:
-
PREF_H1
type
:
TYPE_NORMAL
zh
:
torch.random
-
en
:
原文:[https://pytorch.org/docs/stable/random.html](https://pytorch.org/docs/stable/random.html)
id
:
totrans-1
prefs
:
-
PREF_BQ
type
:
TYPE_NORMAL
zh
:
原文:[https://pytorch.org/docs/stable/random.html](https://pytorch.org/docs/stable/random.html)
-
en
:
'
[PRE0]'
id
:
totrans-2
prefs
:
[]
type
:
TYPE_PRE
zh
:
'
[PRE0]'
-
en
:
Forks the RNG, so that when you return, the RNG is reset to the state that it
was previously in.
id
:
totrans-3
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
分叉RNG,以便在返回时,RNG被重置为先前的状态。
-
en
:
Parameters
id
:
totrans-4
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
参数
-
en
:
'
**devices**
(*iterable*
*of*
*Device
IDs*)
–
devices
for
which
to
fork
the
RNG.
CPU
RNG
state
is
always
forked.
By
default,
[`fork_rng()`](#torch.random.fork_rng
"torch.random.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'
id
:
totrans-5
prefs
:
-
PREF_UL
type
:
TYPE_NORMAL
zh
:
'
**devices**
(*可迭代的*
*设备ID*)
–
要分叉RNG的设备。CPU
RNG状态始终被分叉。默认情况下,[`fork_rng()`](#torch.random.fork_rng
"torch.random.fork_rng")在所有设备上操作,但如果您的机器有很多设备,此函数将运行非常缓慢,将发出警告。如果您明确指定设备,则此警告将被抑制'
-
en
:
'
**enabled**
([*bool*](https://docs.python.org/3/library/functions.html#bool
"(in
Python
v3.12)"))
–
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.'
id
:
totrans-6
prefs
:
-
PREF_UL
type
:
TYPE_NORMAL
zh
:
'
**enabled**
([*bool*](https://docs.python.org/3/library/functions.html#bool
"(在Python
v3.12中)"))
–
如果为`False`,则不分叉RNG。这是一个方便的参数,可以轻松禁用上下文管理器,而无需删除它并将Python代码缩进在其下面。'
-
en
:
'
**deivce_type**
([*str*](https://docs.python.org/3/library/stdtypes.html#str
"(in
Python
v3.12)"))
–
device
type
str,
default
is
cuda.
As
for
custom
device,
see
details
in
[Note:
support
the
custom
device
with
privateuse1]'
id
:
totrans-7
prefs
:
-
PREF_UL
type
:
TYPE_NORMAL
zh
:
'
**deivce_type**
([*str*](https://docs.python.org/3/library/stdtypes.html#str
"(在Python
v3.12中)"))
–
设备类型str,默认为cuda。至于自定义设备,请参阅[注:支持带有privateuse1的自定义设备]'
-
en
:
Return type
id
:
totrans-8
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
返回类型
-
en
:
'
[*Generator*](https://docs.python.org/3/library/typing.html#typing.Generator
"(in
Python
v3.12)")'
id
:
totrans-9
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
'
[*生成器*](https://docs.python.org/3/library/typing.html#typing.Generator
"(在Python
v3.12中)")'
-
en
:
'
[PRE1]'
id
:
totrans-10
prefs
:
[]
type
:
TYPE_PRE
zh
:
'
[PRE1]'
-
en
:
Returns the random number generator state as a torch.ByteTensor.
id
:
totrans-11
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
将随机数生成器状态返回为torch.ByteTensor。
-
en
:
Return type
id
:
totrans-12
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
返回类型
-
en
:
'
[*Tensor*](tensors.html#torch.Tensor
"torch.Tensor")'
id
:
totrans-13
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
'
[*张量*](tensors.html#torch.Tensor
"torch.Tensor")'
-
en
:
'
[PRE2]'
id
:
totrans-14
prefs
:
[]
type
:
TYPE_PRE
zh
:
'
[PRE2]'
-
en
:
Returns the initial seed for generating random numbers as a Python long.
id
:
totrans-15
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
返回生成随机数的初始种子作为Python长整型。
-
en
:
Return type
id
:
totrans-16
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
返回类型
-
en
:
'
[int](https://docs.python.org/3/library/functions.html#int
"(in
Python
v3.12)")'
id
:
totrans-17
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
'
[int](https://docs.python.org/3/library/functions.html#int
"(在Python
v3.12中)")'
-
en
:
'
[PRE3]'
id
:
totrans-18
prefs
:
[]
type
:
TYPE_PRE
zh
:
'
[PRE3]'
-
en
:
Sets the seed for generating random numbers. Returns a torch.Generator object.
id
:
totrans-19
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
设置生成随机数的种子。返回一个torch.Generator对象。
-
en
:
Parameters
id
:
totrans-20
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
参数
-
en
:
'
**seed**
([*int*](https://docs.python.org/3/library/functions.html#int
"(in
Python
v3.12)"))
–
The
desired
seed.
Value
must
be
within
the
inclusive
range
[-0x8000_0000_0000_0000,
0xffff_ffff_ffff_ffff].
Otherwise,
a
RuntimeError
is
raised.
Negative
inputs
are
remapped
to
positive
values
with
the
formula
0xffff_ffff_ffff_ffff
+
seed.'
id
:
totrans-21
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
'
**seed**
([*int*](https://docs.python.org/3/library/functions.html#int
"(在Python
v3.12中)"))
–
所需种子。值必须在包含范围[-0x8000_0000_0000_0000,
0xffff_ffff_ffff_ffff]内。否则,将引发RuntimeError。负输入将使用公式0xffff_ffff_ffff_ffff
+
seed重新映射为正值。'
-
en
:
Return type
id
:
totrans-22
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
返回类型
-
en
:
'
[*Generator*](generated/torch.Generator.html#torch.Generator
"torch._C.Generator")'
id
:
totrans-23
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
'
[*生成器*](generated/torch.Generator.html#torch.Generator
"torch._C.Generator")'
-
en
:
'
[PRE4]'
id
:
totrans-24
prefs
:
[]
type
:
TYPE_PRE
zh
:
'
[PRE4]'
-
en
:
Sets the seed for generating random numbers to a non-deterministic random number.
Returns a 64 bit number used to seed the RNG.
id
:
totrans-25
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
将生成随机数的种子设置为非确定性随机数。返回用于种子RNG的64位数字。
-
en
:
Return type
id
:
totrans-26
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
返回类型
-
en
:
'
[int](https://docs.python.org/3/library/functions.html#int
"(in
Python
v3.12)")'
id
:
totrans-27
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
'
[int](https://docs.python.org/3/library/functions.html#int
"(在Python
v3.12中)")'
-
en
:
'
[PRE5]'
id
:
totrans-28
prefs
:
[]
type
:
TYPE_PRE
zh
:
'
[PRE5]'
-
en
:
Sets the random number generator state.
id
:
totrans-29
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
设置随机数生成器状态。
-
en
:
Parameters
id
:
totrans-30
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
参数
-
en
:
'
**new_state**
(*torch.ByteTensor*)
–
The
desired
state'
id
:
totrans-31
prefs
:
[]
type
:
TYPE_NORMAL
zh
:
'
**new_state**
(*torch.ByteTensor*)
–
所需状态'
totrans/doc22_077.yaml
浏览文件 @
a363d0aa
此差异已折叠。
点击以展开。
totrans/doc22_078.yaml
浏览文件 @
a363d0aa
此差异已折叠。
点击以展开。
totrans/doc22_079.yaml
浏览文件 @
a363d0aa
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录