Code speculation: settings handling

Caveat lector: I am not a dev, or even particular informed about coding; I am however enthusiastically engaged (yay for users! :smiley: ) - but unfortunately that does not prevent me from talking out of my a*s(e) sometimes.


In this question we learn how the notebook code should vary in response to a component setting.

So, when a specific setting (of a setting choice, rather than value) is made only the code relevant to that setting is included in the component code. (NB simple boolean choices that assign True/False to a single variable are obviously not a problem)

This means that behind the scenes, there must be choice-handling code ~if... elif etc. (which can be replaced with case match with python 3.10).

Now, it certainly makes the component code more compact, but it makes code customisation harder (within PL or in jupyter) because once customisation has been performed

  • one cannot change a setting via the settings panel without losing customisations (the component has to be reset to re-enable settings), and
  • one cannot easily change the code for settings because one has to know what the code for all settings is
  • one has to check for multiple locations to update e.g. for both y and y_before

(I mean repeated editing of course; it seems to me highly unlikely that one would only wish to make 1 change to a component)

If on the other hand, the settings were handled by including the if elif in the component code, one would simply need to change the control variable to select the desired piece of code.

Alas, this would significantly complicate the code because some components have several such settings with several choices each, and in notebook form that code will be repeated over and over again for each type of component.


Is there room for a compromise? For example, define all settings handling in one place per component (or global setting function with local parameter) so that e.g. one would have y =activationFn(y) and y_before = activationFn(y_before) , and one place where activationFn was defined - e.g. via a global dictionary of known activation functions

activationFns = {'sigmoid' : tf.nn.sigmoid, 'leakyRelu' : tf.nn.leaky_relu, ...}

then simply

activationFn = activationFns['sigmoid']

Just wondering.

Motivation: I have tested various activation functions on a simple encoder-decoder in order to see how the network behaved in training accuracy, appearance of the results, etc. (with a view perhaps to using observed behaviours to illustrate motivations for activation function choices).

I did this by hand in PL, but I could have coded loops into a notebook which would have been much more efficient.

It might also help with longer term ambitions for Network Architecture Search (NSA), hyperparameter tuning, etc.