Train procedure

Official Content
This documentation is valid for:

Creates and starts training a custom model from a given dataset.



The following table resumes the configuration properties (access credentials) you must set in order to use this AI task.

ProviderType Key
Alibaba -
Amazon -
Baidu -
Google  -
IBM Visual Recognition Key
Microsoft Custom Vision Training Key
Tencent -


Suppose you want to create a model to classify different types of flowers.

First, you must get your tagged data. In this case, we will use the Mamaevs' Flowers Recognition dataset.

Then, you must provide a GeneXus' 'generator' object that must satisfy two conditions:
1) Returns a collection of Data data type.
2) Allows pagination through two input parameters: page number and page size.

In this context, you have two alternatives:

  1. Use a Data Provider
    e.g. if you load the dataset in a Transaction object, you can create a Data Provider object using Skip/Count clauses.
      Output = Data
      Collection = True
      parm(in:&pageNum, in:&pageSize);
      Data [COUNT = &pageSize] [SKIP = (&pageNum - 1) * &pageSize]
                  Value = TransactionBlobAttribute
             Label = TransactionStringCategory
    ​​​​​  }
  2. Use a Procedure
    e.g. if you have your dataset in a directory and every image follows the format '{category}_{index}.png', you can scan the directory with the following Procedure object.
      parm(in:&pageNum, in:&pageSize, out:&DataCollection);
      &i = 0
      &BTM = (&pageNum - 1) * &pageSize + 1
      &TOP = &pageSize * &pageNum
      &directory.Source = !"{path}/dataset" 
      for &file in &directory.GetFiles()
         &i += 1
         do case
            case &i > &TOP
               exit // upper index in range [&BTM,&TOP]
            case &i < &BTM
               // skip - lower index in range [&BTM,&TOP]
              &mediaFilePath = &file.GetAbsoluteName()
              &mediaCategory = &file.GetName().ReplaceRegEx(!"_\d+\.png$",!"") // p.e. "cat1_0001.png" --> "cat1"
              &data = new()
              &data.Output.Label = &mediaCategory

Finally, you can define your model and start the training process:

&definition = new()

// define model name
&definition.Name = !"Flowers model"

// define model dataset (link to generator object previously defined)
&definition.Dataset.Loader = link(MyGeneratorObject)

// define model input
&feature = new()
&feature.Name = !"IMAGE"
&feature.Type = DataInputType.Media

// define model output
&definition.Output.Type = DataOutputType.Label

// call train process
&Model = GeneXusAI.Custom.Train(&definition, &provider, &Messages)


  • This process executes silently (in the provider's server). You can poll the training status by calling the Check procedure.
  • The training process time may vary depending on your input dataset.
  • It is highly important your 'generator' object follows these two rules:
    1) Returns a collection of Data data type.
    2) Allows pagination through two input parameters: page number and page size.
    Also, your 'generator' object must be reachable from your main object because it will be dynamically called from GeneXusAI.


Platforms  Web(.NET,.NETCore,Java), SmartDevices(Android,iOS)
Connectivity  Online


This procedure is available as of GeneXus 16 upgrade 6.

See also

Was this page helpful?
What Is This?
Your feedback about this content is important. Let us know what you think.