Set seed for a Class that calls Keras Models I have class that I use to optimize parameters of a Keras LSTM model. It is known that to set seed for keras, one must input the follow on its code. But what I'm not understanding is where to put it in the case of a class that will build and modify the models.
from numpy.random import seed
seed(1)
from tensorflow.random import set_seed
set_seed(2)

Should it be in the __init__ like bellow?
from numpy.random import seed
from tensorflow.random import set_seed

class OptimizeLSTM:
    def __init__(self, X_train, y_train, X_test, y_test, verbose=False):
        self._X_train = X_train
        self._y_train = y_train
        self._X_test = X_test
        self._y_test = y_test
        self._verbose = verbose
        seed(1)
        set_seed(2)
No you should declare it ahead of the class, just after importing the packages. You have declare the seed for numpy and tensorflow separately. For further details read this blog -
https://machinelearningmastery.com/reproducible-results-neural-networks-keras/