I have defined this method/function in a google colab cell
[5]:def lstm_model2(input_features, timesteps, regularizers=regularizers, batch_size=10):
model = Sequential()
model.add(LSTM(15, batch_input_shape=(batch_size, timesteps,
input_features), stateful=True,
recurrent_regularizer=regularizers))
model.add(Dense(1))
model.compile(loss='mae', optimizer='adam')
return model
I want to pass this method to a script I am executing in the next cell using argparse.
[6]:!python statefulv2.py --model=lstm_model2
I tried an approach similar to type argument in argparse like defining a identically named abstract method inside the statefulv2.py
script so that argparse.add_argument('--model', help='LSTM model', type=lstm_model2, required=True)
can be written inside statefulv2.py
But this raises an invalid argument error.
Is there a neat way to pass methods as arguments in argparse?
The reason for keeping the method outside is to edit it for trying differeny functions since GoogleColab does not provide separate editor for changing model in a separate file.