推理时间表
ContinuousInferenceSchedule
基类:InferenceSchedule
连续时间推理时间表的基础类。
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
__init__(nsteps, inclusive_end=False, min_t=0, padding=0, dilation=0, direction=TimeDirection.UNIFIED, device='cpu')
初始化 ContinuousInferenceSchedule。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
int
|
时间步数。 |
必需 |
inclusive_end
|
bool
|
如果为 True,则在时间表中包含结束值 (1.0),否则在 1.0-1/nsteps 处结束(默认为 False)。 |
False
|
min_t
|
Float
|
最小时间值,默认为 0。 |
0
|
padding
|
Float
|
填充时间值,默认为 0。 |
0
|
dilation
|
Float
|
扩张时间值,默认为 0,即副本数。 |
0
|
direction
|
Optional[str]
|
用于同步时间表的 TimeDirection。如果时间表使用不同的方向定义,则此参数允许翻转方向以匹配指定的方向(默认为 None)。 |
UNIFIED
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
'cpu'
|
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
discretize(nsteps=None, schedule=None, device=None)
将时间表离散化为时间增量列表。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
Optioanl[int]
|
时间步数。如果为 None,则使用初始化时的值。 |
None
|
schedule
|
Optional[Tensor]
|
时间表,如果为 None,将使用 generate_schedule 生成。 |
None
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
None
|
返回
名称 | 类型 | 描述 |
---|---|---|
Tensor |
Tensor
|
时间增量的张量。 |
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
|
DiscreteInferenceSchedule
基类:InferenceSchedule
离散时间推理时间表的基础类。
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
discretize(nsteps=None, device=None)
将时间表离散化为时间增量列表。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
Optioanl[int]
|
时间步数。如果为 None,则使用初始化时的值。 |
None
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
None
|
返回
名称 | 类型 | 描述 |
---|---|---|
Tensor |
Tensor
|
时间增量的张量。 |
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
|
DiscreteLinearInferenceSchedule
基类:DiscreteInferenceSchedule
离散时间推理的线性时间表。
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
__init__(nsteps, min_t=0, padding=0, dilation=0, direction=TimeDirection.UNIFIED, device='cpu')
初始化 DiscreteLinearInferenceSchedule。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
int
|
时间步数。 |
必需 |
min_t
|
Float
|
最小时间值,默认为 0。 |
0
|
padding
|
Float
|
填充时间值,默认为 0。 |
0
|
dilation
|
Float
|
扩张时间值,默认为 0,即副本数。 |
0
|
direction
|
Optional[str]
|
用于同步时间表的 TimeDirection。如果时间表使用不同的方向定义,则此参数允许翻转方向以匹配指定的方向(默认为 None)。 |
UNIFIED
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
'cpu'
|
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
generate_schedule(nsteps=None, device=None)
生成线性时间表作为张量。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
Optional[int]
|
时间步数。如果为 None,则使用初始化时的值。 |
None
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
None
|
返回
名称 | 类型 | 描述 |
---|---|---|
Tensor |
Tensor
|
时间步数的张量。 |
Tensor |
Tensor
|
时间步数的张量。 |
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
InferenceSchedule
基类:ABC
推理时间表的基础类。
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
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 |
|
__init__(nsteps, min_t=0, padding=0, dilation=0, direction=TimeDirection.UNIFIED, device='cpu')
初始化 InferenceSchedule。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
int
|
时间步数。 |
必需 |
min_t
|
Float
|
最小时间值,默认为 0。 |
0
|
padding
|
Float
|
填充时间值,默认为 0。 |
0
|
dilation
|
Float
|
扩张时间值,默认为 0,即副本数。 |
0
|
direction
|
Optional[str]
|
用于同步时间表的 TimeDirection。如果时间表使用不同的方向定义,则此参数允许翻转方向以匹配指定的方向(默认为 None)。 |
UNIFIED
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
'cpu'
|
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
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 |
|
generate_schedule(nsteps=None, device=None)
abstractmethod
生成时间表作为张量。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
Optioanl[int]
|
时间步数。如果为 None,则使用初始化时的值。 |
None
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
None
|
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
58 59 60 61 62 63 64 65 66 67 68 |
|
pad_time(n_samples, scalar_time, device=None)
创建一个形状为 (n_samples,) 的张量,并用标量时间值填充。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
n_samples
|
int
|
输出张量的期望维度。 |
必需 |
scalar_time
|
Float
|
用于填充张量的标量时间值。 |
必需 |
device
|
Optional[Union[str, device]]
|
用于放置张量的设备。默认为 None,使用默认设备。 |
None
|
返回
名称 | 类型 | 描述 |
---|---|---|
Tensor |
Tensor
|
一个形状为 (n_samples,) 的张量,用标量时间值填充。 |
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
LinearInferenceSchedule
基类:ContinuousInferenceSchedule
连续时间推理的线性时间表。
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
__init__(nsteps, inclusive_end=False, min_t=0, padding=0, dilation=0, direction=TimeDirection.UNIFIED, device='cpu')
初始化 LinearInferenceSchedule。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
int
|
时间步数。 |
必需 |
inclusive_end
|
bool
|
如果为 True,则在时间表中包含结束值 (1.0),否则在 1.0-1/nsteps 处结束(默认为 False)。 |
False
|
min_t
|
Float
|
最小时间值,默认为 0。 |
0
|
padding
|
Float
|
填充时间值,默认为 0。 |
0
|
dilation
|
Float
|
扩张时间值,默认为 0,即副本数。 |
0
|
direction
|
Optional[str]
|
用于同步时间表的 TimeDirection。如果时间表使用不同的方向定义,则此参数允许翻转方向以匹配指定的方向(默认为 None)。 |
UNIFIED
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
'cpu'
|
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
generate_schedule(nsteps=None, device=None)
生成线性时间表作为张量。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
Optional[int]
|
时间步数。如果为 None,则使用初始化时的值。 |
None
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
None
|
返回
名称 | 类型 | 描述 |
---|---|---|
Tensor |
Tensor
|
时间步数的张量。 |
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
|
LogInferenceSchedule
基类:ContinuousInferenceSchedule
用于推理的对数时间表,其中时间步长通过取均匀时间表的对数生成。
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
|
__init__(nsteps, inclusive_end=False, min_t=0, padding=0, dilation=0, exponent=-2.0, direction=TimeDirection.UNIFIED, device='cpu')
初始化 LogInferenceSchedule。
返回对数空间时间表。
对于具有默认参数的 100 步,它是
tensor([0.0000, 0.0455, 0.0889, 0.1303, 0.1699, 0.2077, 0.2439, 0.2783, 0.3113, 0.3427, 0.3728, 0.4015, 0.4288, 0.4550, 0.4800, 0.5039, 0.5266, 0.5484, 0.5692, 0.5890, 0.6080, 0.6261, 0.6434, 0.6599, 0.6756, 0.6907, 0.7051, 0.7188, 0.7319, 0.7444, 0.7564, 0.7678, 0.7787, 0.7891, 0.7991, 0.8086, 0.8176, 0.8263, 0.8346, 0.8425, 0.8500, 0.8572, 0.8641, 0.8707, 0.8769, 0.8829, 0.8887, 0.8941, 0.8993, 0.9043, 0.9091, 0.9136, 0.9180, 0.9221, 0.9261, 0.9299, 0.9335, 0.9369, 0.9402, 0.9434, 0.9464, 0.9492, 0.9520, 0.9546, 0.9571, 0.9595, 0.9618, 0.9639, 0.9660, 0.9680, 0.9699, 0.9717, 0.9734, 0.9751, 0.9767, 0.9782, 0.9796, 0.9810, 0.9823, 0.9835, 0.9847, 0.9859, 0.9870, 0.9880, 0.9890, 0.9899, 0.9909, 0.9917, 0.9925, 0.9933, 0.9941, 0.9948, 0.9955, 0.9962, 0.9968, 0.9974, 0.9980, 0.9985, 0.9990, 0.9995])
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
int
|
时间步数。 |
必需 |
inclusive_end
|
bool
|
如果为 True,则在时间表中包含结束值 (1.0),否则在 <1.0 处结束(默认为 False)。 |
False
|
min_t
|
Float
|
最小时间值,默认为 0。 |
0
|
padding
|
Float
|
填充时间值,默认为 0。 |
0
|
dilation
|
Float
|
扩张时间值,默认为 0,即副本数。 |
0
|
exponent
|
Float
|
对数空间指数参数,默认为 -2.0。数字越小,从 0 到 0.9 的加速越激进,因此从 0.9 到 1.0 的步数越多。 |
-2.0
|
direction
|
Optional[str]
|
用于同步时间表的 TimeDirection。如果时间表使用不同的方向定义,则此参数允许翻转方向以匹配指定的方向(默认为 None)。 |
UNIFIED
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
'cpu'
|
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
|
generate_schedule(nsteps=None, device=None)
生成对数时间表作为张量。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
Optional[int]
|
时间步数。如果为 None,则使用初始化时的值。 |
None
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
None
|
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
|
PowerInferenceSchedule
基类:ContinuousInferenceSchedule
用于推理的幂时间表,其中时间步长通过将均匀时间表提升到指定的幂生成。
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|
__init__(nsteps, inclusive_end=False, min_t=0, padding=0, dilation=0, exponent=1.0, direction=TimeDirection.UNIFIED, device='cpu')
初始化 PowerInferenceSchedule。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
int
|
时间步数。 |
必需 |
inclusive_end
|
bool
|
如果为 True,则在时间表中包含结束值 (1.0),否则在 <1.0 处结束(默认为 False)。 |
False
|
min_t
|
Float
|
最小时间值,默认为 0。 |
0
|
padding
|
Float
|
填充时间值,默认为 0。 |
0
|
dilation
|
Float
|
扩张时间值,默认为 0,即副本数。 |
0
|
exponent
|
Float
|
功率参数,默认为 1.0。 |
1.0
|
direction
|
Optional[str]
|
用于同步时间表的 TimeDirection。如果时间表使用不同的方向定义,则此参数允许翻转方向以匹配指定的方向(默认为 None)。 |
UNIFIED
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
'cpu'
|
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
|
generate_schedule(nsteps=None, device=None)
生成幂时间表作为张量。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nsteps
|
Optional[int]
|
时间步数。如果为 None,则使用初始化时的值。 |
None
|
device
|
Optional[str]
|
将时间表放置在哪个设备上(默认为 "cpu")。 |
None
|
返回
名称 | 类型 | 描述 |
---|---|---|
Tensor |
Tensor
|
时间步数的张量。 |
Tensor |
Tensor
|
时间步数的张量。 |
源代码在 bionemo/moco/schedules/inference_time_schedules.py
中
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 |
|