We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
######========== Determinism test ==========###### import numpy as np import tensorflow as tf import random from models import find_model import utils seed = 7171 utils.set_seed(seed) assert seed == 7171, 'Seed must be 7171' assert str(np.sum(np.random.rand(100, 100, 100))) == '499878.65104700223', 'Numpy is not deterministic.' assert str(sum([random.random() for _ in range(1000)])) == '499.1124110048268', 'Random is not deterministic.' class Dataset(tf.keras.utils.Sequence): def __init__(self, n_samples=12, batch_size=4, vol_size=(256,256,64)): self.n_samples = n_samples self.batch_size = batch_size self.vol_size = vol_size def __len__(self): return np.ceil(self.n_samples / self.batch_size).astype(int) def __getitem__(self, index): X = tf.random.normal((self.batch_size, *self.vol_size, 1)) y = np.random.randint(0, 2, self.batch_size) return X, tf.keras.utils.to_categorical(y) data = Dataset() model = find_model('baseline')((*data.vol_size, 1), 2) model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy']) assert str(sum(map(lambda x: x.sum(), model.get_weights()))) == '1055.7722613811493', '[Before fit] Tensorflow is not deterministic.' model.fit(Dataset(), epochs=3, verbose=1) assert str(sum(map(lambda x: x.sum(), model.get_weights()))) == '1066.2186067344155', '[After fit] Tensorflow is not deterministic.'
上記のプログラムを実行すると再現性は取れる.しかし,実際のtrain.pyでは再現性が取れていない.考えられる原因:
train.py
skimage.transform.resize
set_seed()
os.environ['TF_CUDNN_DETERMINISTIC'] = '1'
実験環境:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
上記のプログラムを実行すると再現性は取れる.しかし,実際の
train.py
では再現性が取れていない.考えられる原因:skimage.transform.resize
の再現性の問題set_seed()
:os.environ['TF_CUDNN_DETERMINISTIC'] = '1'
が設定されていない実験環境:
The text was updated successfully, but these errors were encountered: