Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

随机不确定 #79

Open
Lyan-ing opened this issue Dec 3, 2024 · 0 comments
Open

随机不确定 #79

Lyan-ing opened this issue Dec 3, 2024 · 0 comments

Comments

@Lyan-ing
Copy link

Lyan-ing commented Dec 3, 2024

有没有人在训练时遇到每次训练结果不一样的情况,在一开始已经设定了随机种子固定,调试发现,模型在第一次更新参数前是完全一致的,相同的输出产生相同的预测、loss,但是经过一次参数更新后,模型参数和预测就不一样了,这是哪里还有随机的部分没被固定?
def set_seed(random_seed):
random.seed(random_seed)

# NumPy
np.random.seed(random_seed)

# PyTorch
torch.manual_seed(random_seed)
# if torch.cuda.is_available():
torch.cuda.manual_seed(random_seed)
torch.cuda.manual_seed_all(random_seed)
torch.backends.cudnn.deterministic = True
torch.backends.cudnn.benchmark = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant