# ReLU activation function for MLP

**URL:** <https://root-forum.cern.ch/t/relu-activation-function-for-mlp/30569>\
**Category:** TMVA\
**Created:** [September 6, 2018, 5:26pm UTC](https://root-forum.cern.ch/t/relu-activation-function-for-mlp/30569 "2018-09-06T17:26:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![annamascellani](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/a88e4f/32.png) [@annamascellani](https://root-forum.cern.ch/u/annamascellani)\
**Post date:** [September 6, 2018, 5:26pm UTC](https://root-forum.cern.ch/t/relu-activation-function-for-mlp/30569/1 "2018-09-06T17:26:50Z")

</div>

Hi, I’m using the MLP argument for BookMethod of the Factory class for a regression problem. I want to use the ReLU activation function, but this is not among the predefined options. Is there a way to use it with the same ANN configuration?  
Thank you for the attention,  
Anna

---

<div class="post-metadata">

**Author:** ![pseyfert](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pseyfert/32/12287_2.png) [@pseyfert](https://root-forum.cern.ch/u/pseyfert)\
**Post date:** [September 9, 2018, 2:47pm UTC](https://root-forum.cern.ch/t/relu-activation-function-for-mlp/30569/2 "2018-09-09T14:47:37Z")

</div>

Hi,

for the MLP method the option is `NeuronType=ReLU` (with the file in tutorials/tmva/TMVAClassification.C that is:

```auto
      factory->BookMethod( dataloader, TMVA::Types::kMLP, "MLP", "H:!V:NeuronType=ReLU:VarTransform=N:NCycles=600:HiddenLayers=N+5:TestRate=5:!UseRegulator" );

```

With the DNN method it’s an upper case E `Layout=RELU|128,RELU|128,RELU|128,LINEAR` again from the tutorials file that reads:

```auto
      // General layout.
      TString layoutString ("Layout=RELU|128,RELU|128,RELU|128,LINEAR");

      // Training strategies.
      TString training0("LearningRate=1e-1,Momentum=0.9,Repetitions=1,"
                        "ConvergenceSteps=20,BatchSize=256,TestRepetitions=10,"
                        "WeightDecay=1e-4,Regularization=L2,"
                        "DropConfig=0.0+0.5+0.5+0.5, Multithreading=True");
      TString training1("LearningRate=1e-2,Momentum=0.9,Repetitions=1,"
                        "ConvergenceSteps=20,BatchSize=256,TestRepetitions=10,"
                        "WeightDecay=1e-4,Regularization=L2,"
                        "DropConfig=0.0+0.0+0.0+0.0, Multithreading=True");
      TString training2("LearningRate=1e-3,Momentum=0.0,Repetitions=1,"
                        "ConvergenceSteps=20,BatchSize=256,TestRepetitions=10,"
                        "WeightDecay=1e-4,Regularization=L2,"
                        "DropConfig=0.0+0.0+0.0+0.0, Multithreading=True");
      TString trainingStrategyString ("TrainingStrategy=");
      trainingStrategyString += training0 + "|" + training1 + "|" + training2;

      // General Options.
      TString dnnOptions ("!H:V:ErrorStrategy=CROSSENTROPY:VarTransform=N:"
                          "WeightInitialization=XAVIERUNIFORM");
      dnnOptions.Append (":"); dnnOptions.Append (layoutString);
      dnnOptions.Append (":"); dnnOptions.Append (trainingStrategyString);

```

Cheers,  
Paul
