Categories
Misc

How to get reproducibile results in tensorflow?

I’m working on a project based on a conda environment, by using:

  • tensorflow-gpu=2.4.0,
  • cudatoolkit=10.2.89,
  • cudnn=7.6.5.

I’d like to have reproducibile results, so I tried with:

import os import random import numpy as np from numpy.random import default_rng import tensorflow as tf random.seed(0) rng = default_rng(0) tf.random.set_seed(0) 

And launching the python script from the terminal as:

PYTHONHASHSEED=0 python /path/to/main.py 

But my results are not reproducible.

Without posting my code (because is long and includes many files), which could be some other aspects that I should consider in order to get reproducibility?

PS: the Artificial Neural Network is a CNN and is created with by adding layers as, e.g.,:tf.keras.layers.Convolution2D(…)

submitted by /u/RainbowRedditForum
[visit reddit] [comments]

Leave a Reply

Your email address will not be published.