当前位置:网站首页>深度学习随机数设置,保证实验的可重复性
深度学习随机数设置,保证实验的可重复性
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设置随机种子
参考文献:
边栏推荐
- Calculation example of matlab program iEEE9 node system for power flow calculation of AC-DC hybrid system based on alternate iteration method
- 《c语言小游戏》入门级三子棋游戏(机器人加强版)
- 解决win11/win10在登陆界面(解锁界面)点击获取每日壁纸无效的问题 - get Daily Lockscreen and Wallpaper - Win11/10的登录界面背景图片在哪里?
- 嵌入式系统驱动初级【2】——内核模块下_参数和依赖
- 【愚公系列】2022年07月 Go教学课程 022-Go容器之字典
- Introduction and self-order of bcos
- mysql插入新字段方法
- [Interview: Concurrency 37: Multithreading: Thread Pool] Custom Thread Pool
- Shell编程之条件语句
- 2022.07.13 _ a day
猜你喜欢

开源|商品识别推荐系统

shell/bash脚本命令教程

双倍数据速率同步动态随机存储器(Double Data Rate Synchronous Dynamic Random Access Memory, DDR SDRAM)- 逻辑描述部分

《C语言小游戏》扫雷

金融租赁业务

DAY18: Xss Range Clearance Manual

最大似然估计和最小二乘法 含代码

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

Environment_Variable_and_SetUID

The Perfect Guide|How to use ODBC for Agentless Oracle Database Monitoring?
随机推荐
Open Source | Commodity Recognition Recommender System
The first part of the R language
mysql insert new field method
2022.07.22 _ a day
NK - RTU980 burning bare-metal program
2022.07.24_每日一题
关于yum源的配置及更新
Pygame Surface对象
基金投顾业务
Reimbursement Process | By Tianfang
interrupt and pendSV
How to set the computer password?How to add "safety lock" to your computer
强化学习科研知识必备(数据库、期刊、会议、牛人)
[Interview: Concurrency 37: Multithreading: Thread Pool] Custom Thread Pool
2022.07.12_Daily Question
Visual Studio新功能出炉:低优先级构建
MySQL detailed explanation
Navicat new database
Matlab学习第一天(持续更新中)
2022.07.12 _ a day