diff --git a/hist/hist/inc/TFormula.h b/hist/hist/inc/TFormula.h
index 32de78d1565d18eaef2a64d180869fda939f7b9f..729aa22a267b1d7313c4512ac116ffc92c00c07f 100644
--- a/hist/hist/inc/TFormula.h
+++ b/hist/hist/inc/TFormula.h
@@ -263,6 +263,7 @@ public:
    virtual void        Update() {;}
 
    static  void        SetMaxima(Int_t maxop=1000, Int_t maxpar=1000, Int_t maxconst=1000);
+   static  void        GetMaxima(Int_t& maxop, Int_t& maxpar, Int_t& maxconst);
 
    ClassDef(TFormula,8)  //The formula base class  f(x,y,z,par)
 };
diff --git a/hist/hist/src/TFormula.cxx b/hist/hist/src/TFormula.cxx
index efc62bc0854058d841e8bb1c72ce4557a111ea07..9c7583a7b185b91813d21b91f60b3724985e881e 100644
--- a/hist/hist/src/TFormula.cxx
+++ b/hist/hist/src/TFormula.cxx
@@ -4461,3 +4461,16 @@ void TFormula::SetMaxima(Int_t maxop, Int_t maxpar, Int_t maxconst)
    gMAXPAR   = TMath::Max(10,maxpar);
    gMAXCONST = TMath::Max(10,maxconst);
 }
+
+//______________________________________________________________________________
+void TFormula::GetMaxima(Int_t& maxop, Int_t& maxpar, Int_t& maxconst)
+{
+   // static function to get the maximum value of 3 parameters
+   //  -maxop    : maximum number of operations
+   //  -maxpar   : maximum number of parameters
+   //  -maxconst : maximum number of constants
+
+   maxop = gMAXOP;
+   maxpar = gMAXPAR;
+   maxconst = gMAXCONST;
+}
diff --git a/math/mlp/src/TMultiLayerPerceptron.cxx b/math/mlp/src/TMultiLayerPerceptron.cxx
index 3f9aed1d489e2f1a7a5623c912d6a010feb666bb..650d7efa0b624262efa19395a13227d18635817a 100644
--- a/math/mlp/src/TMultiLayerPerceptron.cxx
+++ b/math/mlp/src/TMultiLayerPerceptron.cxx
@@ -1194,6 +1194,12 @@ void TMultiLayerPerceptron::AttachData()
    TNeuron *neuron = 0;
    Bool_t normalize = false;
    fManager = new TTreeFormulaManager;
+
+   // Set the size of the internal array of parameters of the formula
+   Int_t maxop, maxpar, maxconst;
+   TFormula::GetMaxima(maxop, maxpar, maxconst);
+   TFormula::SetMaxima(10, 10, 10);
+   
    //first layer
    const TString input = TString(fStructure(0, fStructure.First(':')));
    const TObjArray *inpL = input.Tokenize(", ");
@@ -1232,6 +1238,9 @@ void TMultiLayerPerceptron::AttachData()
 
    fManager->Add((fEventWeight = new TTreeFormula("NNweight",fWeight.Data(),fData)));
    //fManager->Sync();
+
+   // Set the old values
+   TFormula::SetMaxima(maxop, maxpar, maxconst);
 }
 
 //______________________________________________________________________________