Activation function as a variable

Dear all,

I am trying to set the activation function of a “keras dense layer” node from a flow variable (String: Tanh).

My aim is to have a CSV file so I can build the network (Shapes, types and activation functions) and then read it within knime to avoid open all knime nodes.

It worked with matrix shapes but didn’t work for activation function.

Got this:

“WARN Keras Dense Layer 3:856 Errors loading flow variables into node : Loading model settings failed, caught “IllegalArgumentException”: No enum constant org.knime.dl.keras.core.config.activation.DLKerasActivation.Tanh”

Thanks in advance.

Dear Iceman,

Did you try in uppercase “TANH” ?

A trick I use to know what are the exact expected contents to set the KNIME variables (b.t.w. which sometimes can be quite tricky) is to first set manually the value of the field in the node configuration menu and then associate a new output variable to it so that I know what is exactly the expected constant content to use to set the variable. For instance here:

  1. I set the “activation function” option as “Tanh”:

  2. then I run the node and go to the variables tab of the node:

  1. I associate an output variable “m_activation” to the option I’m interested in, in this case the “m_activation” field:

and I run again the node.

  1. Finally I can see what is the expected constant value to set in the Variables tab of the resulting output view of the node:


Here you can see that the value is not exactly the same as in the options. It is in full uppercase “TANH” so this tells me that the right value to use is this one rather than “Tanh”.

If a need to be sure about all the possible values, I would need to do this for all of them. Once I know all of them, I can associate the option with a variable initialized with one of these possible values. Here it would be any of the options,

but making sure that they are written in uppercase.

It is a bit odd but shows that the content of the variables to configure options do not always exactly correspond to the expected values for the associated variables.

Hope this helps.





Checked and solved.

Good trick


Hi @Iceman

Thanks for your nice comment and glad to read it worked. In this case, could you please check :heavy_check_mark:the answer with the workflow as solved :blush: ? It will help other people to find this trick when looking for a solution.

Thanks & best regards,



This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.