当前位置:网站首页>深度学习随机数设置,保证实验的可重复性
深度学习随机数设置,保证实验的可重复性
2022-07-31 07:13:00 【Mick..】
在深度学习实验的时候,由于代码里面存在大量的随机操作,因此导致实验的可重复性比较差。为了保证实验的可重复性,我们需要对实验中一些随机操作进行设置。
1 python 和 numpy
如果读取数据的过程采用了随机预处理(如RandomCrop、RandomHorizontalFlip等),那么对python、numpy的随机数生成器也需要设置种子。
import random
import numpy as np
random.seed(seed)
np.random.seed(seed)2 pytorch
torch.manual_seed(seed) # 为CPU设置随机种子
torch.cuda.manual_seed(seed) # 为当前GPU设置随机种子
torch.cuda.manual_seed_all(seed) # 为所有GPU设置随机种子
参考文献:
边栏推荐
- Leetcode952. Calculate maximum component size by common factor
- 2022.07.12_每日一题
- 金融租赁业务
- Zabbix6.2 Surprise Release!Especially optimize the performance of medium and large environment deployment!
- MySQL 5.7详细下载安装配置教程
- 2022.07.26_每日一题
- 强化学习科研知识必备(数据库、期刊、会议、牛人)
- 48页智慧城市规划蓝图 解决方案
- Locust 1.0版本引入的变化
- "The C language games" mine clearance
猜你喜欢

【面试:并发篇38:多线程:线程池】ThreadPoolExecutor类的基本概念

Zabbix6.2 Surprise Release!Especially optimize the performance of medium and large environment deployment!

超级详细的mysql数据库安装指南

Visual Studio新功能出炉:低优先级构建

SCI写作指南

机器学习---线性回归、Logistic回归问题相关笔记及实现

《c语言小游戏》入门级三子棋游戏(机器人加强版)

MySQL installation to the last step in the write the configuration file failed?And after the installation steps

2022.07.14_每日一题

XSS靶场prompt.ml过关详解
随机推荐
2022.07.12 _ a day
Super detailed mysql database installation guide
2022.07.26_Daily Question
【Objective-C语言中的@property】
MySQL安装到最后一步 write configuration file 失败 怎么办?及后安装步骤
Pygame Surface对象
CY7C68013A之LED闪烁
linux redis6.2.6配置文件
The first part of the R language
解决安装 Bun 之后出现 zsh compinit: insecure directories, run compaudit for list. Ignore insecure directorie
最大似然估计和最小二乘法 含代码
《c语言小游戏》入门级三子棋游戏(机器人加强版)
进程调度的基本过程
Client navicat installation tutorial
2022.07.18 _ a day
Failure scenarios of @Transactional annotations
2704:寻找平面上的极大点
LED flashing on CY7C68013A
Financial leasing business
Chapter 9 Exceptions try...except...else...finally