在Keras进行的机器学习项目中,随机性的常见来源是什么? [英] What are common sources of randomness in Machine Learning projects with Keras?

查看:353
本文介绍了在Keras进行的机器学习项目中,随机性的常见来源是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可重复性很重要.在一个开源机器学习项目中,我目前正在努力实现这一目标.有什么要看的部分?

Reproducibility is important. In a closed-source machine learning project I'm currently working on it is hard to achieve it. What are the parts to look at?

推荐答案

设置种子

计算机具有伪随机数生成器,这些伪随机数生成器使用称为种子的值进行初始化.对于机器学习,您可能需要执行以下操作:

Setting seeds

Computers have pseudo-random number generators which are initialized with a value called the seed. For machine learning, you might need to do the following:

# I've heard the order here is important
import random
random.seed(0)

import numpy as np
np.random.seed(0)

import tensorflow as tf
tf.set_random_seed(0)
session_conf = tf.ConfigProto(intra_op_parallelism_threads=1,
                              inter_op_parallelism_threads=1)
sess = tf.Session(graph=tf.get_default_graph(), config=session_conf)

from keras import backend as K
K.set_session(sess)  # tell keras about the seeded session

# now import keras stuff

另请参见: sklearn.model_selection.train_test_split 具有random_state参数.

  1. 我每次都以相同的顺序加载数据吗?
  2. 我是否以相同的方式初始化模型?
  3. 您是否使用可能会更改的外部数据?
  4. 您是否使用可能会更改的外部状态(例如datetime.now)?
  1. Am I loading the data in the same order every time?
  2. Do I initialize the model the same way?
  3. Do you use external data that might change?
  4. Do you use external state that might change (e.g. datetime.now)?

这篇关于在Keras进行的机器学习项目中,随机性的常见来源是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆