Fonction PyTorch torch.cuda.seed


Pytorch torch 参考手册Manuel de référence Pytorch torch

torch.cuda.seedC'est une fonction de PyTorch utilisée pour définir la graine aléatoire CUDA. Définit la graine aléatoire pour le périphérique CUDA actuel (fonctionnellement identique à manual_seed).

Définition de fonction

torch.cuda.seed()

Exemple d'utilisation

Exemple

import torch

# Définir la graine aléatoire CUDA
if torch.cuda.is_available():
    torch.cuda.seed()
    x = torch.randn(3, 3).cuda()
    print(f"Tenseur aléatoire sur CUDA : {x}")
else:
    print("CUDA non disponible")

Pytorch torch 参考手册Manuel de référence Pytorch torch

Autres extensions