Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sciann/functionals/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
trainable: Boolean.
False if network is not trainable, True otherwise.
Default value is True.
init_seed: int.
To make weights initialization reproducible.
Default value is True.

# Raises
ValueError:
Expand All @@ -74,6 +77,7 @@ def Functional(
kernel_regularizer=None,
bias_regularizer=None,
trainable=True,
init_seed=None,
**kwargs):
# prepare hidden layers.
if hidden_layers is None:
Expand All @@ -85,7 +89,8 @@ def Functional(
# prepare kernel initializers.
activations, def_biasinit, def_kerinit = \
prepare_default_activations_and_initializers(
len(hidden_layers) * [activation] + [output_activation]
len(hidden_layers) * [activation] + [output_activation],
seed=init_seed
)
if kernel_initializer is None:
kernel_initializer = def_kerinit
Expand Down
2 changes: 2 additions & 0 deletions sciann/utils/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import print_function

import os
import random
import numpy as np
from numpy import pi

Expand Down Expand Up @@ -49,6 +50,7 @@ def set_random_seed(val=1234):
val: A seed value..

"""
random.seed(val)
np.random.seed(val)
if _is_tf_1():
tf.set_random_seed(val)
Expand Down