File size: 2,599 Bytes
ab854b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
---
description: Explore Ultralytics-tailored torch utility features like Model EMA, early stopping, smart inference, image scaling, get_flops, and many more.
keywords: Ultralytics, Torch Utils, Model EMA, Early Stopping, Smart Inference, Get CPU Info, Time Sync, Fuse Deconv and bn, Get num params, Get FLOPs, Scale img, Copy attr, Intersect dicts, De_parallel, Init seeds, Profile
---

# Reference for `ultralytics/utils/torch_utils.py`

!!! note

    Full source code for this file is available at [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/torch_utils.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/utils/torch_utils.py). Help us fix any issues you see by submitting a [Pull Request](https://docs.ultralytics.com/help/contributing/) ๐Ÿ› ๏ธ. Thank you ๐Ÿ™!

---
## ::: ultralytics.utils.torch_utils.ModelEMA
<br><br>

---
## ::: ultralytics.utils.torch_utils.EarlyStopping
<br><br>

---
## ::: ultralytics.utils.torch_utils.torch_distributed_zero_first
<br><br>

---
## ::: ultralytics.utils.torch_utils.smart_inference_mode
<br><br>

---
## ::: ultralytics.utils.torch_utils.get_cpu_info
<br><br>

---
## ::: ultralytics.utils.torch_utils.select_device
<br><br>

---
## ::: ultralytics.utils.torch_utils.time_sync
<br><br>

---
## ::: ultralytics.utils.torch_utils.fuse_conv_and_bn
<br><br>

---
## ::: ultralytics.utils.torch_utils.fuse_deconv_and_bn
<br><br>

---
## ::: ultralytics.utils.torch_utils.model_info
<br><br>

---
## ::: ultralytics.utils.torch_utils.get_num_params
<br><br>

---
## ::: ultralytics.utils.torch_utils.get_num_gradients
<br><br>

---
## ::: ultralytics.utils.torch_utils.model_info_for_loggers
<br><br>

---
## ::: ultralytics.utils.torch_utils.get_flops
<br><br>

---
## ::: ultralytics.utils.torch_utils.get_flops_with_torch_profiler
<br><br>

---
## ::: ultralytics.utils.torch_utils.initialize_weights
<br><br>

---
## ::: ultralytics.utils.torch_utils.scale_img
<br><br>

---
## ::: ultralytics.utils.torch_utils.make_divisible
<br><br>

---
## ::: ultralytics.utils.torch_utils.copy_attr
<br><br>

---
## ::: ultralytics.utils.torch_utils.get_latest_opset
<br><br>

---
## ::: ultralytics.utils.torch_utils.intersect_dicts
<br><br>

---
## ::: ultralytics.utils.torch_utils.is_parallel
<br><br>

---
## ::: ultralytics.utils.torch_utils.de_parallel
<br><br>

---
## ::: ultralytics.utils.torch_utils.one_cycle
<br><br>

---
## ::: ultralytics.utils.torch_utils.init_seeds
<br><br>

---
## ::: ultralytics.utils.torch_utils.strip_optimizer
<br><br>

---
## ::: ultralytics.utils.torch_utils.profile
<br><br>